This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Being a managed entity does not automatically ensure that the entity is refreshed from DB. Quoting from the ejb spec:
3.2.3 Synchronization to the Database The state of persistent entities is synchronized to the database at transaction commit. This synchronization involving writing to the database any updates to persistent entities and their relationships as specified above.An update to the state of an entity includes both the assignment of a new value to a persistent property or field of the entity as well as the modification of a mutable value of a persistent property or field. Synchronization to the database does not involve a refresh of any managed entities unless the refresh operation is explicitly invoked on those entities
Thanks and Regards
Joined: May 04, 2007
Thanks, I thought it works automatically in both ways.
Joined: Jan 01, 2007
I was trying this out practically. Strangely it turns out that the managed is indeed refreshed from the DB after the persist. Here is the code:
And here is the output:
The output suggests that Cust is refreshed with the updated city after it is persisted. I am confused here :confused