-->
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.  [ 2 posts ] 
Author Message
 Post subject: Using Update HQL to update an entire object
PostPosted: Thu Sep 22, 2011 8:41 pm 
Newbie

Joined: Thu Sep 22, 2011 5:21 pm
Posts: 2
I'm trying to do a conditional update where my code looks something like:

Code:
final String hql   = "update myClass obj set obj = :obj where obj.id=:id and obj.hash=:hash";
final Query query = txn.getSession().createQuery(hql);
query.setParameter("obj", myObject)
                        .setInteger("id", myObject.getId())
                        .setLong("hash",  initialHash);
int updatedRecords = query.executeUpdate();


This does the conditional part just fine, but the
Code:
set obj = :obj
part gets turned into the sql
Code:
set idGroup=?


Is there a way for me to have
Code:
set obj = :obj
set the entire object? is there some other grammar to do so?

Thanks.


Top
 Profile  
 
 Post subject: Re: Using Update HQL to update an entire object
PostPosted: Mon Oct 03, 2011 11:57 am 
Newbie

Joined: Thu Sep 22, 2011 5:21 pm
Posts: 2
No reply yet. Is there a better way to do this? Is there some other Type that I can use explicitly in the parameter to have the full object persisted instead of the ID?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.