| Author |
@Version and Locking.
|
Leonardo Carreira
Ranch Hand
Joined: Apr 07, 2009
Posts: 482
|
|
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..
|
Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
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?
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Leonardo Carreira
Ranch Hand
Joined: Apr 07, 2009
Posts: 482
|
|
@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
Joined: Apr 14, 2004
Posts: 10336
|
|
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
Joined: Apr 07, 2009
Posts: 482
|
|
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
Joined: Apr 14, 2004
Posts: 10336
|
|
|
You understand what they terms mean, yes? Then think about it, which is preferable for a multiuser system?
|
 |
Leonardo Carreira
Ranch Hand
Joined: Apr 07, 2009
Posts: 482
|
|
@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
Joined: Apr 14, 2004
Posts: 10336
|
|
Precisely
Is versioning still not working?
|
 |
Leonardo Carreira
Ranch Hand
Joined: Apr 07, 2009
Posts: 482
|
|
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..
|
 |
 |
|
|
subject: @Version and Locking.
|
|
|