[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3762) LockMode.UPGRADE and TABLE_PER_CLASS and PostgreSQL generates usupported SQL
Dobes Vandermeer (JIRA)
noreply at atlassian.com
Sat Feb 7 19:55:38 EST 2009
LockMode.UPGRADE and TABLE_PER_CLASS and PostgreSQL generates usupported SQL
----------------------------------------------------------------------------
Key: HHH-3762
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3762
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1.GA, PostgreSQL 8.2, Hibernate-Annotations, Hibernate-EntityManager, Glassfish v2ur2, Windows Vista 64.bit
Reporter: Dobes Vandermeer
Priority: Minor
I created a class called Job and a few subclasses such as SendEmailJob, ProcessSubscriptionsJob, and so on. I set the inheritance type to TABLE_PER_CLASS since the columns in each are quite different. However, the worker that loads and executes the jobs is the same.
The worker was trying to use a piece of code like this:
@Timeout
public void timeout(Timer timer) {
session.get(Job.class, (Long)timer.getInfo(), LockMode.UPGRADE);
}
PostgreSQL returned the following error:
org.postgresql.util.PSQLException: ERROR: SELECT FOR UPDATE/SHARE is not allowed with UNION/INTERSECT/EXCEPT
The workaround was to lock the object separately, so hibernate only tries to select .. for update from one table:
@Timeout
public void timeout(Timer timer) {
Job job = session.get(Job.class, (Long)timer.getInfo(), LockMode.NONE);
session.refresh(job, LockMode.UPGRADE); // Now there's just one table involved
}
A possible solution to this issue would be for hibernate to do this breakdown automatically when doing a get() on a TABLE_PER_CLASS superclass - i.e. it would ignore LockMode when fetching, but if LockMode is > UPGRADE it would call refresh() with that lock mode on the found object (if any) to lock it. This does introduce an extra SELECT but I can't really think of another solution for this use case.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list