-->
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: Problem generating code
PostPosted: Tue Sep 27, 2005 12:29 pm 
Newbie

Joined: Tue Sep 27, 2005 12:19 pm
Posts: 3
Hi,
I'm trying to generate some code using Hibernate3 tools. The mapping file is:

Code:
<hibernate-mapping default-lazy="false">
    <meta attribute="scope-field">protected</meta>
    <class name="it.satanet.ketol2ws.fm.model.Company" table="company">
        <meta attribute="generated-class">it.satanet.ketol2ws.fm.model.base.CompanyBase</meta>
        <id name="id" type="long">
            <generator class="hilo">
                <param name="table">hibernate_unique_key</param>
                <param name="column">next_hi</param>
                <param name="max_lo">100</param>
            </generator>
        </id>
        <discriminator column="type" type="string" />
        <property name="juridicEntity" column="juridic_entity" type="string" length="100" not-null="true" unique="true" />
        <property name="vatNumber" column="vat_number" type="string" length="20" not-null="true" unique="true" />
        <property name="address" type="string" length="1000" not-null="false" />
        <subclass name="it.satanet.ketol2ws.fm.model.Courier" discriminator-value="COURIER">
            <meta attribute="generated-class">it.satanet.ketol2ws.fm.model.base.CourierBase</meta>
        </subclass>
        <subclass name="it.satanet.ketol2ws.fm.model.Mechanic" discriminator-value="MECHANIC">
            <meta attribute="generated-class">it.satanet.ketol2ws.fm.model.base.MechanicBase</meta>
            <property name="phoneNumber" type="string" not-null="true">
                <column name="phone_number" length="100" not-null="false" />
            </property>
            <property name="faxNumber" column="fax_number" type="string" length="20" not-null="false" />
            <property name="email" type="string" length="200" not-null="false" />
        </subclass>
    </class>
</hibernate-mapping>


The problem is that the generated classes have strange names, like:

Code:
it.satanet.ketol2ws.fm.model.base.CompanyBaseit.satanet.ketol2ws.fm.model.base.CourierBaseit.satanet.ketol2ws.fm.model.base.CourierBaseit.satanet.ketol2ws.fm.model.base.MechanicBaseit.satanet.ketol2ws.fm.model.base.MechanicBase


as you can see in the hibernate tool log:

Code:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.0.5
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using CGLIB reflection optimizer
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/daniele/sviluppo/ketol2ws/fm/src/it/satanet/ketol2ws/fm/configuration/Company.hbm.xml
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] INFO: Mapping class: it.satanet.ketol2ws.fm.model.Company -> company
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.HbmBinder bindSubclass
[hibernatetool] INFO: Mapping subclass: it.satanet.ketol2ws.fm.model.Courier -> company
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.HbmBinder bindSubclass
[hibernatetool] INFO: Mapping subclass: it.satanet.ketol2ws.fm.model.Mechanic -> company
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing extends queue
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing collection mappings
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing association property references
[hibernatetool] 27-set-2005 18.24.01 org.hibernate.cfg.Configuration secondPassCompile
[hibernatetool] INFO: processing foreign key constraints
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: **************************************************************
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Starting Jakarta Velocity v1.4
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: RuntimeInstance initializing.
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Trying to use logger class org.apache.velocity.tools.generic.log.CommonsLogLogSystem
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Using logger class org.apache.velocity.tools.generic.log.CommonsLogLogSystem
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Resource Loader Instantiated: org.apache.velocity.runtime.resource.loader.FileResourceLoader
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: FileResourceLoader : initialization starting.
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: FileResourceLoader : adding path '.'
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: FileResourceLoader : initialization complete.
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Resource Loader Instantiated: org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ClasspathResourceLoader : initialization starting.
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ClasspathResourceLoader : initialization complete.
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceCache : initialized. (class org.apache.velocity.runtime.resource.ResourceCacheImpl)
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Default ResourceManager initialization complete.
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Literal
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Macro
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Parse
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Include
[hibernatetool] 27-set-2005 18.24.01 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Created: 20 parsers.
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : initialization starting.
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : allowInline = true : VMs can be defined inline in templates
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : allowInlineLocal = false : VMs defined inline will be  global in scope if allowed.
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : messages on  : VM system will output logging messages
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : autoload off  : VM system will not automatically reload global library macros
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocimacro : initialization complete.
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: Velocity successfully started.
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/javaclass.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 27-set-2005 18.24.02 org.hibernate.tool.hbm2x.POJOExporter runVelocity
[hibernatetool] INFO: Writing it.satanet.ketol2ws.fm.model.base.CompanyBaseit.satanet.ketol2ws.fm.model.base.CourierBaseit.satanet.ketol2ws.fm.model.base.CourierBaseit.satanet.ketol2ws.fm.model.base.MechanicBaseit.satanet.ketol2ws.fm.model.base.MechanicBase to /home/daniele/sviluppo/ketol2ws/fm/src/it/satanet/ketol2ws/fm/model/base/CompanyBaseit/satanet/ketol2ws/fm/model/base/CourierBaseit/satanet/ketol2ws/fm/model/base/CourierBaseit/satanet/ketol2ws/fm/model/base/MechanicBaseit/satanet/ketol2ws/fm/model/base/MechanicBase.java
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/javaclass.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 27-set-2005 18.24.02 org.hibernate.tool.hbm2x.POJOExporter runVelocity
[hibernatetool] INFO: Writing it.satanet.ketol2ws.fm.model.base.CompanyBaseit.satanet.ketol2ws.fm.model.base.CourierBaseit.satanet.ketol2ws.fm.model.base.CourierBaseit.satanet.ketol2ws.fm.model.base.MechanicBaseit.satanet.ketol2ws.fm.model.base.MechanicBase to /home/daniele/sviluppo/ketol2ws/fm/src/it/satanet/ketol2ws/fm/model/base/CompanyBaseit/satanet/ketol2ws/fm/model/base/CourierBaseit/satanet/ketol2ws/fm/model/base/CourierBaseit/satanet/ketol2ws/fm/model/base/MechanicBaseit/satanet/ketol2ws/fm/model/base/MechanicBase.java
[hibernatetool] 27-set-2005 18.24.02 org.apache.velocity.tools.generic.log.CommonsLogLogSystem logVelocityMessage
[hibernatetool] INFO: ResourceManager : found pojo/javaclass.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
[hibernatetool] 27-set-2005 18.24.02 org.hibernate.tool.hbm2x.POJOExporter runVelocity
[hibernatetool] INFO: Writing it.satanet.ketol2ws.fm.model.base.CompanyBase to /home/daniele/sviluppo/ketol2ws/fm/src/it/satanet/ketol2ws/fm/model/base/CompanyBase.java
BUILD SUCCESSFUL


It seems that the tool concatenates the provided subclass names.
Is it a bug or is there a mistake in the mapping?
Thank you in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 1:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
set inherit="false" on the attributes you dont want to apply to "children"

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 3:57 am 
Newbie

Joined: Tue Sep 27, 2005 12:19 pm
Posts: 3
Thank you, now the code generation works well!


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.