java - OneToMany: reference to parent entity is not up to date in child after parent was updated -
i have classical one-to-many relation. read list of child entities database using session.createquery() approach filter required small amount of child entities. each child has reference parent entity. update fields of parent entity , save (see in logs , db changes persisted). when parent child entity child.getparent() still returns reference parent object fields values before update. when new child entity constructed instead of reading db using session.createquery() problem not appear - fields of referenced parent entity contains actual values. problem beans got using session.createquery()? advice appreciated.
you have set "changed parent" child once more:
parent parenttoupdate;  ... child.setparent(parenttoupdate);  ... session.persist(child);   if want transmit change database should persist them.
Comments
Post a Comment