Hello,
i want to read a object out of the database and lock it while/ immediate after reading.
I only found this way:
Code:
session.lock(object, lockMode)
and of course HQL.
Unfortunately, both are NOT compatible with my application design, cause i read with the aid of logics.
Now i'm looking for a solution like the following :
Code:
ArticleLogic al = new ArticleLogic();
al.setFilter(ArticleLogic.FILTER_SERIAL_NUMBER, "123456");
al.setFilter(ArticleLogic.FILTER_LOCK, true);
Article tempArticle = al.unique();
tempArticle.setStatus("reserved");
session.update(tempArticle);
It should produce a SQL statement like this:
SELECT * FROM article WITH (UPDLOCK) WHERE serial_number = '123456'
The selected record should immediate gets locked.
I hope someone recognize my need and help me out.
Thanks and regards,
MK