-->
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: Wrong package name generated by hbm2java for a sub-subclass
PostPosted: Mon Mar 13, 2006 12:50 pm 
Newbie

Joined: Mon Mar 13, 2006 10:22 am
Posts: 2
Location: Zurich, Switzerland
Hibernate version: Hibernate 3.1.2
Hibernate-tools version: hibernate-tools-3.1.0.beta4

Hi List,
I'm experiencing a somewhat weird behaviour of hbm2java when mapping the following class hierarchy:

Code:
AbstractExampleEvent <-- ExampleEvent <-- ExampleSportsEvent

using the attached mapping.

The generated class for "ExampleSportsEvent" (using the meta "generated-class" tag) which is mapped as a subclass of "ExampleEvent" is generated with a ridiculous package name of:

Code:
ch.unartig.studioserver.model.GeneratedExampleEventch.unartig.studioserver.model.GeneratedExampleSportsEventch.unartig.studioserver.model

instead of just:
Code:
ch.unartig.studioserver.model


The problem only occurs for the sub-subclass mapping.

Creating (or renaming) the abstract classes manually everything seems to be fine with the posted mapping. Am I missing something?

Thanks a lot,
Alex

Mapping documents:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class
            name="ch.unartig.studioserver.model.AbstractExampleEvent"
            table="AbstractExampleEvents"
            >
        <meta attribute="generated-class" inherit="false">ch.unartig.studioserver.model.GeneratedAbstractExampleEvent</meta>
        <meta attribute="scope-class" inherit="false">public abstract</meta>
        <cache usage="read-write"/>

        <id
                name="abstractExampleEventId"
                type="java.lang.Long"
                >
            <meta attribute="use-in-tostring">true</meta>
            <generator class="native">
                <param name="sequence">sequence_abstractExampleEventId</param>
            </generator>
        </id>
        <discriminator column="HIERARCHY_LEVEL" type="string"/>

        <property
                name="displayTitle"
                type="java.lang.String"
                length="255"
                not-null="true"
                >
            <meta attribute="use-in-tostring">true</meta>
        </property>

        <!--first hierarchy level after abstract base event :  Event-->
        <subclass name="ch.unartig.studioserver.model.ExampleEvent">
            <meta attribute="generated-class">ch.unartig.studioserver.model.GeneratedExampleEvent</meta>
            <meta attribute="scope-class" inherit="false">public abstract</meta>

            <!--second hierarchy level under ExampleEvent :  SportsEvent-->
            <subclass name="ch.unartig.studioserver.model.ExampleSportsEvent">
                <meta attribute="generated-class">ch.unartig.studioserver.model.GeneratedExampleSportsEvent</meta>
                <meta attribute="scope-class" inherit="false">public abstract</meta>
            </subclass>
        </subclass>
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 1:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you should put inherit="false" on all "generated-class" attributes.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 17, 2006 5:46 pm 
Newbie

Joined: Mon Mar 13, 2006 10:22 am
Posts: 2
Location: Zurich, Switzerland
max wrote:
you should put inherit="false" on all "generated-class" attributes.


... of course. Thanks a lot, Max, for that quick hint.
Alex

_________________
Alexander Josef, unartig.ch


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.