Hibernate version: 3.2.5
using DB2 9.5 with XML which allows me to have embedded XML documents (which are searchable via SQL) in special XML columns. have only two operative tables (plus 2 supporting type tables with foreign keys on the type id):
Code:
Element
---------
elementid
elementtypeid
(booking keeping columns)
management (xml column)
Relationship
--------------
relationshipid
relationshiptypeid
(booking keeping columns)
management (xml column)
i want to represent a unidirectional one-to-many association från the elementid (in the Element table) to xml nodes in the management column of the Relationship table. for example:
Code:
Element (elementid) ----> Relationship ($management://Source/Identification/Id)
read about patch (HHH-2086) from Xavier Brénuchon allowing formulas with one-to-many associations. might do the trick (but that patch doesn't work on 3.2.5 and as stated in the JIRI likely only works with 3.2.0.cr4). the association in the Element.hbm.xml file would be as:
Code:
<set name="sourceRelationships" lazy="true" cascade="save-update" where="TOTIMESTAMP is null">
<key column="ELEMENTID" formula="XMLCAST (XMLQUERY('declare namespace rel="http://fk.se/matrix/management/baseRelationship" declare namespace core="http://fk.se/matrix/management/core" $doc//rel:Source/rel:Identification/core:Id' passing management as "doc") as INTEGER)" on-delete="noaction" not-null="false"/>
<one-to-many class="matrix.v.test.pojo.cmdb.Relationship" />
</set>
can't confirm the above until applying the patch to 3.2.0.cr4. wondering if anybody has a better idea how the association can be mapped? in the database model there is no foreign key between element/relationship tables but the association is important for using Hibernate Criteria queries. a formula of some kind with raw SQL is a must likely any solution.
thanks in advance / Matthew