-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: refresh and locking memory objects
PostPosted: Fri Jul 27, 2007 10:48 am 
Newbie

Joined: Tue May 29, 2007 6:23 pm
Posts: 11
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 20, 2007 8:14 am 
Newbie

Joined: Tue May 29, 2007 6:23 pm
Posts: 11
Hi once more,
If is there any way to prevent an object form getting refreshed by using lock() method on it. What I mean is something like the folowing:

class A {
OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.REFRESH})
List<B> blist;
void add(B b) {}
}

......

//EntityManager em is opened
...
A a = new A();
B b = new B();
a.add(b);
em.persist(a);

// in another transaction another B instance is added to a within a different entity manager.

em.lock(b, LockModeType.READ);

// to associate the newly added B object to em.
em.refresh(a);
...........

Will this lock be able to prevent b to be refreshed?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 20, 2007 8:36 am 
Newbie

Joined: Tue May 29, 2007 6:23 pm
Posts: 11
well lock() requires a transaction and this again is an unwanted situtation for our case. This gets more confusing each time...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.