• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@Version and Locking.

 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends..

i have a mapping table with Hibernate Annotation..
i added @Version like this..


but the value not changed every updates...

does the value would be changed every update or i have to set the value manually?
does all of the entities has to has field @Version?..

if i created transaction by Locking (LockMode.UPGRADE)..
do i have to use field @Version also..

sorry for the basic question.. iam confused..

Thanks in advance..
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you commiting your transaction? The Version will be incremented each successful update.

LockModes are for pessimistic locking, version is for optimistic locking. Which one are you trying to use?
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Paul Sturrock

Thanks sir for your reply..

Yes i have commited my transaction.. but the field @Version value not updated..
is my configuration true?..

Which one is good for implementation Pessimistic Locking or Optimistic Locking?..

Thanks in advance..
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Which one is good for implementation Pessimistic Locking or Optimistic Locking?..


Which one do you need? It depends on your requirements. If you are not sure google the two terms before changing your Hibernate code any more.

Are you saying that version sometimes works or never works?
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yap, the version never work.. always have 0 (zero) value every updated..

for web application, which one is common implementation? (Pessimistic Locking or Optimistic Locking)..
Thanks..
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You understand what they terms mean, yes? Then think about it, which is preferable for a multiuser system?
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Paul Sturrock

Okay thanks sir..

the field @Version could be updated every updates to My Table..

My conclusion is.. Yap the preferable for multiuser is using Optimistic Locking..

Thanks in advance sir..
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Precisely

Is versioning still not working?
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yap sir..

The versioning can working now..
i did a silly mistake, i forgot to add the line of code like this :


Okay thanks in advance sir..
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic