Hallo all,
I am quite new to Hibernate. What I am now having as a problem is that I have to use my Set objects as list. For example I am having a Structure.hbm.xml file which has this many to many relation:
Code:
<set name="eintraege" lazy="true" cascade="none" table="DUFIS_GECONT_MAP" >
<key>
<column name="GECONT_ID" />
</key>
<many-to-many class="geneon.duf.server.shared.domain.Eintrag" fetch="select">
<column name="IDENTNR" />
<column name="BUAB_NUMMER"/>
</many-to-many>
</set>
And my Eintrag.hbm.xml has this relationship
Code:
<set
name="structureItem"
lazy="true"
cascade="none"
table="DUFIS_GECONT_MAP"
>
<key>
<column name="IDENTNR"/>
<column name="BUAB_NUMMER"/>
</key>
<many-to-many
class="geneon.duf.server.shared.domain.StructureItem"
>
<column name="GECONT_ID"/>
</many-to-many>
</set>
So that's why I have Set in my POJOs. What I but need is List object instead of Set. So there was (I didn't write it it was ready) a kind of macro in build.xml which has
Code:
<macrodef name="replace-set-by-list">
<attribute name="key-column"/>
<attribute name="index-column"/>
<attribute name="one2many-name"/>
<attribute name="one2many-class"/>
<attribute name="one2many-mapping"/>
<attribute name="many2one-name"/>
<attribute name="many2one-mapping"/>
<attribute name="inverse"/>
<attribute name="cascade"/>
<sequential>
<replaceregexp flags="s" match="<set\s+(
)*name="@{one2many-name}"\s*(
)*((\w|-)+="[^<>"'&]*"\s*)*>\s*(
)*<key>\s*<column name="@{key-column}"\s*/>\s*</key>\s*(
)*<one-to-many\s+class="${domain-package}.@{one2many-class}"\s*/>\s*(
)*</set>" replace="
<list
name="@{one2many-name}"
lazy="true"
inverse="@{inverse}"
cascade="@{cascade}"
>
<key column="@{key-column}"/>
<list-index column="@{index-column}"/>
<one-to-many class="${domain-package}.@{one2many-class}"/>
</list>
">
<fileset dir="${src.dir}" includes="**/${domain-path}/@{one2many-mapping}.hbm.xml"/>
</replaceregexp>
<addOrSetAttribute tag="many-to-one" attribute="update" value="false" name="@{many2one-name}" mapping="@{many2one-mapping}"/>
<addOrSetAttribute tag="many-to-one" attribute="insert" value="false" name="@{many2one-name}" mapping="@{many2one-mapping}"/>
</sequential>
</macrodef>
Actually I would like to use this macro but I have 2 problems:
1) I am having a many2many relationship
2) I am also having another third table between StructureItem and Eintrag.
So how can I manage to change the object type from Set to List via a macro definition?[/code]