-->
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: Need help to build a macro solution in build.xml
PostPosted: Tue Apr 08, 2008 4:44 am 
Newbie

Joined: Tue Apr 08, 2008 4:22 am
Posts: 2
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="&lt;set\s+(
                    )*name=&quot;@{one2many-name}&quot;\s*(
                    )*((\w|-)+=&quot;[^&lt;&gt;&quot;&apos;&amp;]*&quot;\s*)*&gt;\s*(
                    )*&lt;key&gt;\s*&lt;column name=&quot;@{key-column}&quot;\s*/&gt;\s*&lt;/key&gt;\s*(
                    )*&lt;one-to-many\s+class=&quot;${domain-package}.@{one2many-class}&quot;\s*/&gt;\s*(
                    )*&lt;/set&gt;" replace="
                    &lt;list
                            name=&quot;@{one2many-name}&quot;
                            lazy=&quot;true&quot;
                            inverse=&quot;@{inverse}&quot;
                            cascade=&quot;@{cascade}&quot;
                            &gt;
                        &lt;key column=&quot;@{key-column}&quot;/&gt;
                        &lt;list-index column=&quot;@{index-column}&quot;/&gt;
                        &lt;one-to-many class=&quot;${domain-package}.@{one2many-class}&quot;/&gt;
                    &lt;/list&gt;
                ">
            <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]


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.