Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Scanario based question

 
Geeta Puttappanavar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Geeta Puttappanavar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic