-
1. Re: EntityQuery: Qury data before flush
mconroy Aug 26, 2009 8:48 PM (in response to crnobog)
Is there a way of convincing the hibernate to include the unflushed child in the result of the Query?Is there a reason you don't want to flush newly persisted child? I would modify the code to be
Child c=new Child(); c.setParent(activeParent); persist(c); childList.refresh();
The above code assumes that the persist() method is an extension of an EntityHome. You could do away with the childList.refresh() call if you @Override the ChildQuery.refresh method and add an @Observer to receive the org.jboss.seam.afterTransactionSuccess.Child event callback.
-
2. Re: EntityQuery: Qury data before flush
crnobog Aug 27, 2009 9:06 AM (in response to crnobog)Thank you for your answer Matt
Is there a reason you don't want to flush newly persisted child?Yes there is. I would like to treat the whole thing as one (complex) entity. So if a user makes some changes to the Child list and cancels the conversation before saving the Parent, everything must get rolled back. Flushing the child immediately brakes this principle.
To be more specific. Parent's save method is the only point where I want the data to be flushed.Child c=new Child(); c.setParent(activeParent); persist(c); childList.refresh();
The above code assumes that the persist() method is an extension of an EntityHome. You could do away with the childList.refresh() call if you @Override the ChildQuery.refresh method and add an @Observer to receive the org.jboss.seam.afterTransactionSuccess.Child event callback.The persist I use is actually a EntityHome.getEntityManager().persist(c).
This is because I'm adding a child on ParentHome component. It seems that this one does not fire the org.jboss.seam.afterTransactionSuccess which is kinda logical.
But when I use the a ChildeHome.persist, child gets flushed immediately and of course that is something I don't want. After the data is flushed, childList.refresh() works anyway, so I don't see why I would need the @Observer.
Perhaps I just don't understand it's behavior correctly. I would appreciate some more info on your suggestion.