Java Reference
In-Depth Information
The types of fields supported by JDO for entities include:
Core types supported by Bigtable, as shown in Table 7-1
An array of core datastore type values
A Collection of core datastore type values
@PersistenceCapable class instances or Collections
Serializable class instances or Collections (stored as a Blob)
Embedded classes that are stored as entity properties
As noted, a field value can be an instance of a class that is marked as
@PersistenceCapable . A single instance creates a one-to-one relationship while a
collection creates a one-to-many relationship. Using these types of relationships can
dramatically increase object-modeling and code-writing productivity. For instance,
you can create an Order class that defines an Address class as a persistent field. When
your application creates an instance of the Order class, populates the address field
with a new Address instance, and then saves the Order, the datastore will create both
the Order and Address entities for you. The key of the Address entity has the key of
the Order entity as its entity parent group.
Another object-modeling approach is to use embedded classes for persisting field
values. With embedded classes the fields are stored directly in the datastore entity of
the containing instance and do not exist as separate classes. Any data class marked as
@PersistenceCapable can be used to embed in another data class. There is no need to
specify a primary key field for the object as it is not stored as a self-referencing object.
@Persistent
@Embedded(members = {
@Persistent(name="mailingAddress", columns=@Column(name="address1")),
@Persistent(name="mailingCity", columns=@Column(name="city1")),
@Persistent(name="mailingState", columns=@Column(name="state1")),
@Persistent(name="mailingPostalCode",
columns=@Column(name="postalCode1")),
})
private Address address;
Since embedded classes are stored as part of the actual entity itself, you can use them
with dot notation in JDOQL query filters and sort orders.
Select from Order Where address.mailingState = "KY"
 
Search WWH ::




Custom Search