-->
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 Update Example
PostPosted: Wed Jan 16, 2008 10:49 am 
Newbie

Joined: Tue May 08, 2007 3:34 pm
Posts: 19
I am trying to create an HQL Update statement and would like someone to provide me an example with a simple join on another table.

Here is the basic example I am looking for:
update tablea
set cola
where tablea.cola = tableb.cola
and tablea.colb = tableb.colb

Any help is appreciated.
Joe


I found a way that works and I am posting it in case someone needs an example.

String queryString = "update CustomAttributeInstance" +
" set VALUE = '" + value + "'" +
" where ATTRIBUTE||MODULE in (select ATTRIBUTE||MODULE " +
" from CustomAttributes where ATTRIBUTE_DATATYPE = 'String')" +
" and ROLE_ID = ? and JOURNAL_CODE = ? " +
" and MODULE = ? and ATTRIBUTE = ?" ;

Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, new Integer(role_id));
queryObject.setParameter(1, journal_code);
queryObject.setParameter(2, module);
queryObject.setParameter(3, attribute);
queryObject.executeUpdate();


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.