-->
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.  [ 4 posts ] 
Author Message
 Post subject: update multiplerecords with hql(give alias name)
PostPosted: Thu Mar 06, 2008 12:26 pm 
Newbie

Joined: Fri Nov 16, 2007 3:05 pm
Posts: 14
Hi Guys,

I have problem in updating multiple rows using hql.

This is my mapping:

<hibernate-mapping package="com.nyse.mks.chip.businessSystem.vo">

<class name="GroupParticipantLink" table="group_participant_link" lazy="false">
<composite-id name="groupParticipantLinkKey" class="GroupParticipantLinkKey">
<key-property name="caseId" type="string" column="case_id"/>
<key-property name="eventSeq" type="integer" column="event_seq"/>
<key-property name="groupSeq" type="integer" column="group_seq"/>
<key-property name="participantId" type="integer" column="participant_id"/>
<key-property name="parentParticipantId" type="integer" column="parent_participant_id"/>
</composite-id>
<property name="childParticipantStatus" type="string" column="child_participant_status"/>
</class>


</hibernate-mapping>

The hql update query that i am currently using is:

update GroupParticipantLink gpl set gpl.childParticipantStatus=? where gpl.groupParticipantLinkKey.caseId=?
and gpl.groupParticipantLinkKey.eventSeq=? and gpl.groupParticipantLinkKey.groupSeq=?
and gpl.groupParticipantLinkKey.parentParticipantId=?

But this query is not working. I am getting error stating that
( expecting "set", found 'gpl' ).

I tried removing the alias name, then i am not getting this error.
But my problem , i need to access the properties inside my composite
primarykey object. I dont know how to access it without using alias name.

Can some one help me on this.


Hibernate version:Hibernate3.0

Code between sessionFactory.openSession() and session.close():

session = getOutsiderSession();
int updatedEntities = session.createQuery(hqlUpdate)
.setString(0,childParticipantStatus)
.setString(1,key.getCaseId())
.setInteger(2,key.getEventSeq())
.setInteger(3,key.getGroupSeq())
.setInteger(4,efpParticipantId)
.executeUpdate();

closesession(session)




thanks in advance.


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 6:19 am 
Newbie

Joined: Tue Feb 27, 2007 7:24 am
Posts: 10
Quote:
update GroupParticipantLink gpl set gpl.childParticipantStatus=? where gpl.groupParticipantLinkKey.caseId=?
and gpl.groupParticipantLinkKey.eventSeq=? and gpl.groupParticipantLinkKey.groupSeq=?
and gpl.groupParticipantLinkKey.parentParticipantId=?


In SQL I'm pretty sure you would write this as

update GroupParticipantLink as gpl set childParticipantStatus=? where ....

Try that?

David


Top
 Profile  
 
 Post subject: update multiplerecords with hql(give alias name)
PostPosted: Fri Mar 07, 2008 7:09 am 
Newbie

Joined: Fri Nov 16, 2007 3:05 pm
Posts: 14
Hi David,

I have tried using sql directly. But hibernate throws me an exception stating that "update can be done only through HQl".


Top
 Profile  
 
 Post subject: update multiplerecords with hql(give alias name)
PostPosted: Fri May 02, 2008 4:27 am 
Newbie

Joined: Fri Nov 16, 2007 3:05 pm
Posts: 14
Hi Guys,

I was able to give alias name in update hql query using the
hibernate 3.1.2 version.
So hibernate users, who wants to give alias name in hql bulk update query
can use Hibernate 3.1.2 version.

I hope this will be usefull.

thanks,
krishna.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.