• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

@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..
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic