The following (simplified version of our) code passes our JUnit tests under Hibernate, but not under EclipseLink. What is needed to make this work under EclipseLink?
public static void store(EntityManager em, String a, String b) {
Entry entry=new Entry();
entry.setFirst(a);
entry.setLast(b);
em.persist(entry);
em.persist(new SubEntry(entry.getId(), a, b));
}
It fails because entry.getId() is returning 0 when using EclipseLink. What is the appropriate way to retrieve the unique identifier of an object that has just been stored?
It appears obvious that the above code doesn't make sense, as doing an entry.getId() before the transaction has been committed probably does not make sense, however hibernate allowed it.