-->
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.  [ 2 posts ] 
Author Message
 Post subject: hbm2java 3.1beta2 inheritence issue
PostPosted: Thu Jan 12, 2006 9:45 am 
Newbie

Joined: Tue Oct 04, 2005 1:20 pm
Posts: 16
Location: The Netherlands
Hibernate version: 3.1

Mapping documents:
Code:
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
                      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"                           "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="nl.acc.model">
   <class name="SuperClazz" table="superclazz">
      <meta attribute="scope-class">public abstract</meta>
      <meta attribute="generated-class" inherit="false">nl.acc.model.hibernate.BaseSuperClazz</meta>
      <meta attribute="implement-equals">true</meta>
      <id name="id" type="java.lang.Long">
         <meta attribute="use-in-equals">true</meta>
         <generator class="native" />
      </id>
      <property name="p1" type="string" not-null="true" />
      <property name="p2" type="character" not-null="false" />
      <property name="p3" type="string" not-null="false" />
      <joined-subclass name="SubClazz"
         table="subclazz">
         <meta attribute="generated-class" inherit="false">nl.acc.model.hibernate.BaseSubClazz</meta>
         <key column="id" />
      </joined-subclass>
   </class>
</hibernate-mapping>


hbm2java generates the following constructors from this mapping:

Code:
public abstract class BaseSubClazz extends nl.acc.model.SuperClazz implements java.io.Serializable {
    /** default constructor */
    public BaseSubClazz() {
    }

   /** minimal constructor */
    public BaseSubClazz(String p1) {
        super(p1);       
    }
   
    /** full constructor */
    public BaseSubClazz(String p1, Character p2, String p3) {
        super(p1, p2, p3);
    }
...
}


This code implies that I have to implement constructors which accept arguments (p1, p2, p3) and (p1) in my concrete SubClazz, which is not very elegant. Why does beta2 generate a "minimal" and "full" constructor anyway? The approach of beta1 (a default and id constructor) worked for me.

Kind regards,
Bas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 11:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh because the tools always did it before we reimplemented this for the H3 tools and users asked for it ;)

you can avoid them by removing the code that generates it in the templates.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.