File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate generates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate generates "bad" SQL in Bulk update" Watch "Hibernate generates "bad" SQL in Bulk update" New topic

Hibernate generates "bad" SQL in Bulk update

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
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:

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:

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.
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Well, the beautiful sound of crickets is gratifying, but I have trouble believing that no one in the history of the universe has ever attempted an HQL Update query before. Seriously? no one?

Well, consider this a bump, then, I guess.
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Has anybody got a solution to this? I have the same problem

Hibernate seems to append a ',' after the table name in the update HQL


Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
I ended up using getSession().createQuery(hql).executeUpdate() instead.

hope this helps...
Suresh Kumar Ramasamy

Joined: Mar 18, 2008
Posts: 7
More than an year old thread. When I googled for "hibernate update generates additional comma", I got this as the first result. Hence thought of updating my experience. For me, even getSession().createQuery(hql).executeUpdate() doesn't work. (I am still at With further luck, I came across this Hibernate (non)issue. Hope this is useful to someone.
I agree. Here's the link:
subject: Hibernate generates "bad" SQL in Bulk update
It's not a secret anymore!