-->
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.  [ 3 posts ] 
Author Message
 Post subject: hbm2java ignoring or duplicating class-code
PostPosted: Thu Jan 13, 2005 11:15 am 
Newbie

Joined: Thu Oct 14, 2004 10:05 am
Posts: 9
Location: Copenhagen, Denmark
Hi.

I am trying to (write a program to) write hibernate mappings for a legacy database, and using hbm2java to generate java classes from these mappings.

Currently one of my hibernate mapping look like this:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>

   <class name="com.bmd.bs400.file.Customer" table="CustomerL1" lazy="true">

      <id name="Customernr" column="AJAENB"
         type="com.bmd.bs400.hibernate.CustomernrUserType">
         <meta attribute="use-in-equals">true</meta>
         <meta attribute="use-in-tostring">true</meta>
         <generator class="native" />
      </id>

      <property name="postnr" column="AJAICD"
         type="com.bmd.bs400.hibernate.PostnrUserType">
         <meta attribute="use-in-equals">true</meta>
         <meta attribute="use-in-tostring">true</meta>
      </property>

      <property name="momskode" column="AJJANB"
         type="com.bmd.bs400.hibernate.MomskodeUserType">
         <meta attribute="use-in-equals">true</meta>
         <meta attribute="use-in-tostring">true</meta>
      </property>

      <!-- Includes  SidstRettet -->
      <component name="sidstRettet"
          class="com.bmd.bs400.file.SidstRettet">
         <property name="aendretDato" column="AJALDT"
            type="com.bmd.bs400.hibernate.AendretDatoUserType" />
         <property name="ajourfoeringsstatus" column="AJCDST"
            type="com.bmd.bs400.hibernate.AjourfoeringsstatusUserType" />
         <property name="aendretKlokken" column="AJAATM"
            type="com.bmd.bs400.hibernate.AendretKlokkenUserType" />
         <property name="aendretAf" column="AJAAVN"
            type="com.bmd.bs400.hibernate.AendretAfUserType" />
      </component>


      <set name="Subscribers" inverse="true" lazy="true">
         <meta attribute="scope-get">private</meta>
         <meta attribute="scope-set">private</meta>
         <meta attribute="extra-import">
            com.bmd.bs400.file.Subscriber
         </meta>
         <meta attribute="class-code">
            public void addSubscriber(Subscriber Subscriber) {
               if (Subscriber == null)
                  throw new IllegalArgumentException("Null Subscriber");
               if (Subscriber.getCustomer() != null)
                  Subscriber.getCustomer().getSubscribers().remove(Subscriber);
               Subscriber.setCustomer(this); this.Subscribers.add(Subscriber);
            }
         </meta>
         <key>
            <column name="AJAENB" />
         </key>
         <one-to-many class="com.bmd.bs400.file.Subscriber" />
      </set>

   </class>

</hibernate-mapping>


From this hbm2java generates two classes Customer.java and SidstRettet.java, but the extra-import and class-code meta tags are completely ignored.

If I move them outside the <set> they are included in BOTH Customer.java and SidstRettet.java.

Thats not very usefull - is there a way to have some java code included in Customer.java without having it repeated in all its components?

Best regards
Claus Nielsen


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 12:24 pm 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
try it with "inherit=false" ...

and put the "extra-import" and "class-code" out of the set.

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 4:02 am 
Newbie

Joined: Thu Oct 14, 2004 10:05 am
Posts: 9
Location: Copenhagen, Denmark
curio wrote:
try it with "inherit=false" ...


Thanks - that was exactly what I was missing.

Best regards
Claus Nielsen


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.