I don't kow if this is an issue with Hibernate or Spring, but I'm using the Spring HibernateDaoSupport class from Spring for my Dao.
When calling a bulkUpdate, Hibernate is generating "bad" SQL. Essentially, the SQL generator is adding a comma after the table name, which causes an SQL Exception.
Here's the function call:
Code:
public int expireActiveByDevice(Device device, Date endTime, Boolean asTimeout) {
return getHibernateTemplate().bulkUpdate("update Session set endTime = ?, timeout = ? where endTime is null and provisioningProfile.device = ?", new Object[] { endTime, asTimeout, device });
}
The relevant Entities are
Session, which contains a reference to a
ProvisioningProfile, which itself refers to a
Device. (foreign keys all around.)
The SQL that hibernate is generating is:
Code:
Hibernate:
update
apns.Session,
set
endTime=?,
timeout=?
where
(
endTime is null
)
and deviceId=?
As you can see, that extraneous comma, right after "apns.Session" is causing the problem. This SQL is just not valid.
Has anyone else had this problem? How can I fix this?
I'm using Hibernate 3.3.2 GA and Spring 2.5.6.