File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate Scanario based question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Scanario based question" Watch "Hibernate Scanario based question" New topic
Author

Hibernate Scanario based question

Geeta Puttappanavar
Ranch Hand

Joined: Jan 18, 2012
Posts: 43
Hi to all,

I’ve the scenario based Hibernate question.

There is 1 person name “Sony” with age 25. Admin A will get requirement to update his age from 25 to 21. He’ll fetch the details from DB & by this time he’ll not update, at the same he’ll get call & he’ll leave the place
Now other admin B will come he too wants to update Sony’s age from 25 to 30. So he’ll fetch the date from DB & updates it.
Now the admin A will come & updates Sony’s age from 25 to 21.

Now my questions are that
1. Can admin A update Sony’s age?
2. If yes is it the correct way?
3. If it is not correct way then how to avoid this?

Waiting fir your reply.
Thanks & Regards,
Geeta

Hemant Thard
Ranch Hand

Joined: Dec 23, 2008
Posts: 122
Hi geeta,

I think what you need is an optimistic lock on your person Object.
here is an article that tells you how you can apply optimistic lock on your bean.

Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

This can also be done using annotations. See the reference guide:

http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e1108


[How To Ask Questions][Read before you PM me]
Geeta Puttappanavar
Ranch Hand

Joined: Jan 18, 2012
Posts: 43
Hemant Thard wrote:Hi geeta,

I think what you need is an optimistic lock on your person Object.
here is an article that tells you how you can apply optimistic lock on your bean.



Thank you so much. I got it..
Geeta Puttappanavar
Ranch Hand

Joined: Jan 18, 2012
Posts: 43
Bill Gorder wrote:This can also be done using annotations. See the reference guide:

http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e1108


Thanks Bill. I try the example..
Geeta Puttappanavar
Ranch Hand

Joined: Jan 18, 2012
Posts: 43
Geeta Puttappanavar wrote:
Hemant Thard wrote:Hi geeta,

I think what you need is an optimistic lock on your person Object.
here is an article that tells you how you can apply optimistic lock on your bean.



Thank you so much. I got it..


Hi Hemanth,

Can you please explain that how the optimistic lock will happen in the above example??

Thanks,
Geeta
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Scanario based question