What is workaround for Select for update query in Hibernate?
Issue
-
Following is the issue description which can cause the problem
-
There is special kind of entity exists which has ID (primary key) field which is dependent on other fields of the table.
-
The ID field has some internal dependency on the other fields, which are being used to generate the next value for ID field.
-
For such id field, next value cannot be generated through sequence or through some auto-increment logic.
-
Simple
SELECT FOR UPDATEquery withJDBC APIscan be used to implement this logic but it may not work with clustered environment due to Database lock if multiple threads are trying to access same code.
-
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 5.x
- 6.x
- JBoss Hibernate
- 3.x
- 4.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
