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.  [ 5 posts ] 
Author Message
 Post subject: Updating with Hibernate - please for urgent help
PostPosted: Tue Jan 10, 2006 7:14 am 
Beginner
Beginner

Joined: Tue Nov 22, 2005 6:55 am
Posts: 41
I have a simple code:

Code:
int updatedEntities = getHibernateTemplate().executeFind(new HibernateCallback() {

             public Object doInHibernate(Session session) throws HibernateException {

                return session.createQuery(
                        "UPDATE CustomerActionModel customerAction " +
                        "set customer = (select Customer  customer where " +
                        "customer.customerId = customerAction.customerId) where customerAction.userTask.objecId = ?")
                        .setLong(0,userTask.getObjectId().longValue()).executeUpdate();
                       
             }
         });



The method executeUpdate() is undefined for the type Query...

If put list() here it works (ofcourse if i remove updatedEntities)

But i would like to have an info if any of rows have been updated...
The int value would be mostly appreciated


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 12:11 pm 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

executeUpdate should work.
What version of hibernate do you use?
Mapping files ?

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 12:57 pm 
Beginner
Beginner

Joined: Tue Nov 22, 2005 6:55 am
Posts: 41
version 2.x


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 1:01 pm 
Beginner
Beginner

Joined: Tue Nov 22, 2005 6:55 am
Posts: 41
version of jar is 2.1.6

if it's not apprpriate, could u show me how to update ?

I haven't found sollution yet

The hql query should be as I show above and I would like to know if the update was successful or not.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 4:16 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

can you simplify the update and see what happens ?
like

Code:
"UPDATE CustomerActionModel customerAction " +
                        "set customer = 1 where customerAction.userTask.objecId = ?"

or

Code:
"UPDATE CustomerActionModel customerAction " +
                        "set customer = (select Customer  customer where " +
                        "customer.customerId = customerAction.customerId)"

_________________
dont forget to rate !


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

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.