Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

In short, an embeddable is a seperation of data into a Java class that relies on the owning Entity for it's identity. Many(most) times an embeddable resides in the same database row as the owning Entity.

Review the getting started page on how to run the samples.

Samples

Schema

Class diagram

...

Code Block
titleJPQL.java
borderStylesolid
...
// Select Entity based off a query over a collection of embeddables
Query q = em.createQuery("SELECT u FROM User u , in (u.addresses) a WHERE a.state='xx'");
// TODO -- add more!
...

Relationships from Embeddables

...

Code Block
titleJPQL.java
borderStylesolid

...
// Embedded -> relationship traversal
Query q = em.createQuery("SELECT u FROM User u , in (u.addresses) a WHERE a.coordinates.longitude=xxx");
// TODO -- add more!
...

Nested Embeddables

In the code snippet below, there is a User Entity which has an embedded ContactInfo. ContactInfo contains two other embeddeded embeddables, Address and Phone.

...

Code Block
titleJPQL.java
borderStylesolid

...
// Nested embeddables traversal
Query q = em.createQuery("SELECT u FROM User u WHERE u.contactInfo.homePhone.number='507-555-5555' AND u.contactInfo.homePhone.type='cell'");
// TODO -- add more!
...