Hi,
I'm implementing a DAO method to retrieve the next id in a column using pessimistic blocking, so I'm sure that anyone else uses the same number (what would derivate in a primary key violation).
My code is:
Integer maximo = null;
Query query = session
.createQuery(
"select max(padre.bloqueo)+1 from PadreVO padre")
.setLockMode("padre", LockMode.UPGRADE_NOWAIT);
while (true)
{
try
{
maximo = (Integer) query.uniqueResult();
break;
}
catch (HibernateOptimisticLockingFailureException e)
{
}
}
return maximo;
But I'm getting this exception:
java.lang.IllegalArgumentException: alias not found: padre
If I don't specify the select clause to my HSQL query, then it works great, but obviously don't get the desired result.
Any ideas?
|