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.