Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
2 replies
Subscribers
7 subscribers
Views
2228 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Am trying to implement Optimistic lock in our Applications and gave @Version JPA
jegadeeswaran
over 8 years ago
Am trying to implement Optimistic lock in our Applications and gave @Version JPA Anotations to the version_id integer field in a CDT. CDT has many parent to child relationship. Value of the version_id is not incremented even after writing the particular transaction to DB2. Could you please let us know whether we need to define the column in DB2 as Auto Increment to make it work or it should work even without that. Thanks in advance.
OriginalPostID-176763
OriginalPostID-176763
Discussion posts and replies are publicly visible
Parents
0
Eduardo Fuentes
Appian Employee
over 8 years ago
- Make sure your @Version field in the XSD is marked as "NOT NULL".
- Also keep in mind that the version will be updated only if the value to write is different from the originally retrieved value. Since that's the purpose of the @Version annotation.
The @Version annotation is used for optimistic locking to detect and prevent collisions through a version-check upon commit; if the version number retrieved is different from the current one in the database the update fails with an OptimisticLockException, and you cannot write the values back because you now have dirty data; old data which has been already overridden by somebody else.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Eduardo Fuentes
Appian Employee
over 8 years ago
- Make sure your @Version field in the XSD is marked as "NOT NULL".
- Also keep in mind that the version will be updated only if the value to write is different from the originally retrieved value. Since that's the purpose of the @Version annotation.
The @Version annotation is used for optimistic locking to detect and prevent collisions through a version-check upon commit; if the version number retrieved is different from the current one in the database the update fails with an OptimisticLockException, and you cannot write the values back because you now have dirty data; old data which has been already overridden by somebody else.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data