-->
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.  [ 8 posts ] 
Author Message
 Post subject: HBM2DDL fails on <composite-element>
PostPosted: Wed Nov 19, 2008 11:00 am 
Newbie

Joined: Mon Nov 17, 2008 11:11 am
Posts: 4
Location: Israel
I am trying to port my hibernate application from Oracle to DB2.
I created a minimal hibernate.properties file (that contains the dialect specification), put all the necessary JAR files in the classpath and ran the tool on all the *.hbm.xml files.
Everything works fine until it tries to process an hbm file that has the following code (which is exactly as explained in section 8.2 in the Hibernate Reference manual):

Code:
<set    name="workingItems"
        lazy="true"
   table="MA_COMMAND_WORKING_ITEM">
   <key column="COMMAND_ID"/>
   <composite-element class="com.acme.data.pojo.ManagementAuthorityCommandWorkingItem">
        <property name="id" column="ID" not-null="true"/>
        <property name="action" column="ACTION" not-null="true"/>
        <property name="workingItemId" column="WORKING_ITEM_ID" not-null="true"/>
   </composite-element>         
</set>


I do NOT have the class listed in the <composite-element> as this is not needed and works fine with my code.
Here is the output from the tool:

Code:
SEVERE: Error creating schema
org.hibernate.MappingException: class com.acme.data.pojo.ManagementAuthorityCommandWorkingItem not found while looking for property: id
   at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:74)
   at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
   at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2164)
   at org.hibernate.cfg.HbmBinder.bindComponent(HbmBinder.java:1893)
   at org.hibernate.cfg.HbmBinder.bindComposite(HbmBinder.java:1692)
   at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2448)
   at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652)
   at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
   at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:687)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:93)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:61)
   at org.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:394)
Caused by: java.lang.ClassNotFoundException: com.acme.data.pojo.ManagementAuthorityCommandWorkingItem
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClassInternal(Unknown Source)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
   at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:70)
   ... 12 more
[/code]

Any help, pointers, RTFM's are welcome.

_________________
-- Amir


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 10:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
how are you running this ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: I am running it from the DOS command line
PostPosted: Thu Nov 20, 2008 11:01 am 
Newbie

Joined: Mon Nov 17, 2008 11:11 am
Posts: 4
Location: Israel
Code:
@echo off
REM
REM Set up CLASSPATH of all JAR files needed by hbm2ddl
REM

set JBLIB=%JBOSS_HOME%\server\default\lib

set HCFG=".\hibernate.cfg.xml"

set A01=.\hibernate3.jar
set A02=%JBLIB%\commons-logging.jar
set A03=%JBLIB%\dom4j.jar
set A04=%JBLIB%\commons-collections.jar

set CLASSPATH=%A01%;%A02%;%A03%;%A04%

java org.hibernate.tool.hbm2ddl.SchemaExport   --text  --properties=hibernate.properties --output=zzz.sql *.hbm.xml

_________________
-- Amir


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 11:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
how are you running this ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: From the DOS command line
PostPosted: Thu Nov 20, 2008 11:24 am 
Newbie

Joined: Mon Nov 17, 2008 11:11 am
Posts: 4
Location: Israel
max wrote:
how are you running this ?


I start a DOS command window in the folder where all the HBM.XML files are. As I posted earlier, in the script, all the necessary JARs are in the CLASSPATH, so that is not the problem - the problem seems to be in one specific HBM file with the <composite-element> tag.

_________________
-- Amir


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 12:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I don't see any references to user classes in your classpath.

p.s. Adding a lib directory to a classpath does not automatically add all *.jar's in it

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 1:17 pm 
Newbie

Joined: Mon Nov 17, 2008 11:11 am
Posts: 4
Location: Israel
max wrote:
I don't see any references to user classes in your classpath.

p.s. Adding a lib directory to a classpath does not automatically add all *.jar's in it


1. My understanding is that HBM2DDL does not need my classes, only my HBM files
2. The tool was successful on all HBM files except the one that has the <composite-element>. I guess this proves my point...(or maybe not?)

_________________
-- Amir


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2008 4:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
since you haven't listed any type info on your nested properties hibernate need to look up the type on the class - how else would it know what type to put in the database schema ?

So yes, it can work without classes but then you have to put types on all your hbm.xml files.

_________________
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.  [ 8 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.