facebook

@hibernate.subclass is not generating correct hbm.xml file

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #217840 Reply

    Erick Dovale
    Member

    Hello there guys,

    Here goes the issue:

    
    /**
     * @hibernate.class table = "table_A" 
     * @hibernate.discriminator column = "disc_column" length = "10"
    */
    interface A {
     /* some method */
    }
    
    /**
     * @hibernate.subclass discriminator-value = "classB" 
    */
    class B implements A{
    /* some methods */
    }
    
    

    The mapping generated does not includes the subclass definition although it does contains the discrimitar column.

    here goes the mapping:

    <?xml version=”1.0″ encoding=”UTF-8″?>

    <!DOCTYPE hibernate-mapping PUBLIC
    “-//Hibernate/Hibernate Mapping DTD 2.0//EN”
    http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd”&gt;

    <hibernate-mapping>
    <class name=”model.User” table=”User” dynamic-update=”false”
    dynamic-insert=”false” select-before-update=”false”>

    <id name=”id” column=”id” type=”int” unsaved-value=”-1″>
    <generator class=”native”>
    <!–
    To add non XDoclet generator parameters, create a file named
    hibernate-generator-params-User.xml
    containing the additional parameters and place it in your merge dir.
    –>
    </generator>
    </id>

    <discriminator column=”usertype” length=”10″ />

    <property name=”myFirstName” type=”java.lang.String”
    update=”true” insert=”true” access=”property” column=”firstname”
    length=”30″ />

    <property name=”myIsActive” type=”boolean” update=”true”
    insert=”true” access=”property” column=”isactive” />

    <property name=”myLastLogon” type=”java.util.Date” update=”true”
    insert=”true” access=”property” column=”lastlogon” />

    <property name=”myLastName” type=”java.lang.String”
    update=”true” insert=”true” access=”property” column=”lastname”
    length=”30″ />

    <property name=”myPassword” type=”java.lang.String”
    update=”true” insert=”true” access=”property” column=”password”
    length=”20″ />

    <property name=”myUsername” type=”java.lang.String”
    update=”true” insert=”true” access=”property” column=”username”
    length=”30″ />

    <!–
    To add non XDoclet property mappings, create a file named
    hibernate-properties-User.xml
    containing the additional properties and place it in your merge dir
    –>

    </class>

    </hibernate-mapping>

    #217894 Reply

    Scott Anderson
    Participant

    edovale,

    The mapping generated does not includes the subclass definition although it does contains the discrimitar column.

    I don’t believe the discriminator value is actually supposed to be the classname, according to what I read in the hibernate documentation. There’s a really nice tutorial that seems to cover this issue at the IBM website here:
    http://www-106.ibm.com/developerworks/java/library/j-hibern/

    #217897 Reply

    Erick Dovale
    Member

    I don’t believe this is the problem. I have tested with different values for the discriminator and regardless of it xdoclet does not generate the proper tags in the hbm.xml file.
    I recall having read about a bug in xdoclet regarding this. The question would be if you guys have a fix for it.

    Thanks.

    #217898 Reply

    Scott Anderson
    Participant

    I recall having read about a bug in xdoclet regarding this. The question would be if you guys have a fix for it.

    For XDoclet fixes, we typically wait for the XDoclet team to release them and then integrate the new version into each service release of MyEclipse. So, we don’t have a specific fix for this one. However, if the XDoclet team has released a fix, you can
    update the modules used by MyEclipse yourself by following the instructions in the MyEclipse User Guide, available here:
    http://myeclipseide.com/enterpriseworkbench/help/topic/com.genuitec.myeclipse.doc/html/gettingstarted/xdoclet-overview/core/refresh.html

    #219387 Reply

    Matt Raible
    Member

    I had this same problem, but it was because I was spelling descriminator wrong. Once I changed it to be discriminator-value=”VALUE”, the mapping was generated correctly. I’m using XDoclet 1.2.2.

    #219420 Reply

    Scott Anderson
    Participant

    Matt,

    Thanks for pointing this out. It’s a tricky error to diagnose.

    By the way, “Happy Joining-MyEclipse Anniversary”. 😉

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: @hibernate.subclass is not generating correct hbm.xml file

You must be logged in to post in the forum log in