-->
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: UPDATE..SET HQL statement with Hibernate Collections
PostPosted: Tue Oct 17, 2006 11:03 am 
Newbie

Joined: Tue Oct 17, 2006 10:34 am
Posts: 3
Hi forum,

I have a hbm file (which holds some patch information) that uses a set:

Code:
<set name="m_dependentPatches" cascade="all" table="tbl_dependentPatches" lazy="false">
       <key column="patch_id"/>
       <element type="java.lang.Long" column="dep_patch_id"/>
</set>



i.e. I have a Patch table that contains information like id, name, description, etc. and another "Dependent Patches" table, which will hold <patch id, dependent patch id> pairs. The latter is accomplished by the 'm_dependentPatches' which you can see in the above snippet.

Now coming to my problem. I am trying to update the dependent patches for a patch using the HQL named query:

Code:
update PatchData p set p.m_dependentPatches=:dependentPatches where p.m_patchId=:patchId


In my code, before querying, I am writing:

Code:
Set depPatchSet = new HashSet();
depPatchSet.add(Long.valueOf(1));
query.setParameter("dependentPatches",                depPatchSet);
query.executeUpdate();


(This is because dependent patch set is a set of Long objects, i.e. the dependent patch ids wrapped as Long)

However, the result is that Hibernate is parsing the query properly, and is throwing an exception. UPDATE..SET is working for other non-collection objects like Date, String, etc.
I am not sure of how to write UPDATE..SET statement in one-to-many collections like these.

Kindly help me in this regard.

Thanks in advance.

Regards,
Kumar Iyer.


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.