I have the table from which I want to get unique values for some entities.
| public class UniqueGenerator
| {
| @Id
| @Column(...)
| private String id;
|
| @Column(...)
| private Long currentValue;
| ...
| }
|
Then in data access layer I have to write this code to retrieve next value:
| ...
| gen = entityManager.find(UniqueGenerator.class, MY_GENERATOR_ID);
| entityManager.lock(gen, LockModeType.WRITE);
| entityManager.refresh(gen);
|
| Long currVal = gen.getCurrentValue();
| ...
|
Hibernate translate it to these 3 queries:
| 1. SELECT .. FROM UNIQUE_GENERATORS WHERE ...
| 2. SELECT GENERATOR_ID FROM UNIQUE_GENERATORS WHERE ...FOR UPDATE
| 3. SELECT .. FROM UNIQUE_GENERATORS WHERE ...
|
Is there any way to make Hibernate doing only one query:
| SELECT ... FROM UNIQUE_GENERATORS WHERE ... FOR UPDATE
|
?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163207#4163207
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4163207
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user