consider following:
@entity public class mainentity { @onetoone(orphanremoval = true, cascade = cascadetype.all) private childentity childentity; } @entity public class childentity { @onetomany(cascade = cascadetype.all) @lazycollection(false) private list<anotherentity> otherentities; }
now, when first call
final childentity anewchild = new childentity(); anewchild.addotherentity(anotherentity); //several entities can added here mainentity.setchildentity(anewchild); entitymanager.persist(mainentity);
everything works fine, , updates, long after transaction finished.
final childentity anothernewchild = new childentity(); anothernewchild.addotherentity(anotherentity); //several entities can added here mainentity.setchildentity(anothernewchild); //a log of log.info(mainentity); shows fields appropriately set //at point during merge operation, new childentity need persisted. //according logs, invocation of entitymanager.persist(anothernewchild) occurs, during merge propagated new entity. //at point childentity.otherentities detected null return entitymanager.merge(mainentity);
the problem that, persist,
list<anotherentity>
is not null , not empty, while on merge,
list<anotherentity>
is null
i doing on ejb remote invocation.
hibernate 4.3.6 wildfly 8.1.0 jpa 2.1
is there missing here?
reproduced issue following code:
https://github.com/marembo2008/hibernate-jpa-bug
opened issue on hibernate issue tracker.
the problem merge returns new entity, should this:
mainentity = entitymanager.merge(mainentity);