-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to retrieve new version value once object is updated?
PostPosted: Sun Jul 05, 2009 3:15 am 
Newbie

Joined: Fri May 30, 2008 10:37 am
Posts: 10
I have a requirement that once the entity is persisted, the new version value must be returned back to the client side in order to prevent concurrency issues in future calls.

Code:
      Employee emp1 = dao.findById(new Short((short) 13));
      emp1.setCity("cmb");      
      EntityManagerHelper.beginTransaction();
      System.out.println(emp1.getVersion());
      Employee updatedEmp = dao.update(emp1);
      System.out.println(updatedEmp.getVersion());
      EntityManagerHelper.commit();



However, I found that when the version value is retrieved from the returned object of Hibernate update/merge operation, it is not incremented. Is there a way to get the updated version value as part of the update operation?


Top
 Profile  
 
 Post subject: Re: How to retrieve new version value once object is updated?
PostPosted: Sun Jul 05, 2009 11:30 am 
Beginner
Beginner

Joined: Wed Jun 17, 2009 9:03 pm
Posts: 31
Location: mumbai
Try to use entityManager.refresh(Object) to reload the object. I guess it will return the current value of version column.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.