Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA EclipseLink @OneToMany returns empty set
    text
    copied!<p>I am using an embedded id:</p> <pre><code>@Embeddable public class EntityId { private long id; } </code></pre> <p>And I have the following tables:</p> <pre><code>@Entity public class Master { @EmbeddedId private EntityId id; @OneToMany(mappedBy = "master") Set&lt;Config&gt; configs; } @Entity public class SlaveLeft { private @EmbeddedId EntityId id; } @Entity public class SlaveRight { private @EmbeddedId EntityId id; } @Entity public class Config { @EmbeddedId private EntityId id; @ManyToOne @JoinColumn(name = "MASTER_ID", referencedColumnName = "id") private Master master; @ManyToOne @JoinColumn(name = "LEFT_ID", referencedColumnName = "id") private SlaveLeft slaveLeft; @ManyToOne @JoinColumn(name = "RIGHT_ID", referencedColumnName = "id") private SlaveRight slaveRight; } </code></pre> <p>I then populate the database:</p> <pre><code> final EntityManager em = injector.getInstance(EntityManager.class); em.getTransaction().begin(); Master master = new Master(EntityId.next()); SlaveLeft slaveLeft = new SlaveLeft(EntityId.next()); SlaveRight slaveRight = new SlaveRight(EntityId.next()); Config config = new Config(EntityId.next(), master, slaveLeft, slaveRight); em.persist(master); em.persist(slaveLeft); em.persist(slaveRight); em.persist(config); em.getTransaction().commit(); final Master master1 = em.find(Master.class, master.getId()); System.out.println(master1.getConfigs()); </code></pre> <p>The problem is that the master1.getConfigs() returns empty.</p> <p>What am I missing to get a working relation?</p>
 

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