Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not possible, you cannot query an <code>Embeddable</code>. From the JPA Wikibook:</p> <blockquote> <h2><a href="http://en.wikibooks.org/wiki/Java_Persistence/ElementCollection#Embedded_Collections" rel="noreferrer">Embedded Collections</a></h2> <p>An <code>ElementCollection</code> mapping can be used to define a collection of <code>Embeddable</code> objects. This is not a typical usage of <code>Embeddable</code> objects as the objects are not embedded in the source object's table, but stored in a separate collection table. This is similar to a <code>OneToMany</code>, except the target object is an <code>Embeddable</code> instead of an <code>Entity</code>. This allows collections of simple objects to be easily defined, without requiring the simple objects to define an <code>Id</code> or <code>ManyToOne</code> inverse mapping. <code>ElementCollection</code> can also override the mappings, or table for their collection, so you can have multiple entities reference the same Embeddable class, but have each store their dependent objects in a separate table.</p> <p>The limitations of using an <code>ElementCollection</code> instead of a <code>OneToMany</code> is that <strong>the target objects cannot be queried</strong>, persisted, merged independently of their parent object. They are strictly privately-owned (dependent) objects, the same as an <code>Embedded</code> mapping. There is no cascade option on an <code>ElementCollection</code>, the target objects are always persisted, merged, removed with their parent. <code>ElementCollection</code> still can use a fetch type and defaults to LAZY the same as other collection mappings.</p> </blockquote> <p>To achieve what you want, use a <code>OneToMany</code> and an <code>Entity</code> instead of an <code>ElementCollection</code> and an <code>Embeddable</code>. Or change your approach and query the <code>Person</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload