-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HQL Bulk update generates "bad" SQL?
PostPosted: Wed Nov 11, 2009 10:25 am 
Beginner
Beginner

Joined: Tue Feb 03, 2009 4:33 pm
Posts: 21
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.