Hi to all,
For our two-tier Swing application, and having read the discussions found on hibernate.org and other java forums, we have decided to use a never closed entitymanager for read purposes(lazy load, refresh, find...), and all other write purposed operations we open&close temporary entity managers. The application has a tree from where new entities can be inserted or deleted. For a paste action in the tree, the addition is done using temporary entity manager. But for the newly inserted elements to get attached to the long-live read only entity manager, the parent entity is refreshed but this causes all the earlier added children to get refreshed too(since refresh is cascaded). For our application, this is not a wanted condition since all the lower level entities may be opened for editing in different tabs and refreshing will override their values. For this purpose, is there any mechanism to lock memory objects (specially lock children objects that are added earlier), or any other advices would be very helpful, thanks in advance. We are using annotations and JPA specification but are ready to use any hibernate specific methods or so if it helps.
|