-->
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: Generate java code from hbm.xml
PostPosted: Sun Jan 29, 2006 7:55 pm 
Newbie

Joined: Sun Jan 29, 2006 7:45 pm
Posts: 5
I am using 3.1.2

I spent searching around for a while at google and here. I am stuck with a simple problem.

I have a "Book.hbm.xml" and I want to generate "Book.java" using "hibernatetool".

I have ant tasks defined and i got past all the "classpath" issues. Now the hibernate tries to instantiate "Book", which is the class I am trying to generate. Somehow I am not telling it to generate. I am suspecting that I am not specifying something in the cfg.xml. I dont know what.

The Book.hbm.xml is

<?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="Book" table="BOOK">
<meta attribute="class-description">
A Book business object.
@author Duke
</meta>
<id name="id" type="string" unsaved-value="null" >
<column name="BOOK_ID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<property column="BOOK_NAME" name="name"/>
<property column="BOOK_ISBN" name="isbn">
<meta attribute="field-description">
The unique ISBN code for this book.
</meta>
</property>
</class>

</hibernate-mapping>


The hibernate.cfg.xml is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="AutoSchoolHibernate">
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://server=localhost;port=1433;DatabaseName=interlacemain;SelectMethod=cursor</property>
<property name="hibernate.connection.username">interlace</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

</session-factory>
</hibernate-configuration>



The error msg I am getting is:

Caused by: org.hibernate.MappingException: Could not read mapping document from file: C:\work\programs\autoschool\base\main\hibernate\basic\Book.hbm.xml
at org.hibernate.cfg.Configuration.addFile(Configuration.java:270)
at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:140)
... 37 more
Caused by: org.hibernate.MappingException: class Book not found while looking for property: name
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:80)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2138)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2115)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2005)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:368)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:282)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:267)
... 38 more
Caused by: java.lang.ClassNotFoundException: Book
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1166)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1107)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:977)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:76)
... 48 more
--- Nested Exception ---

Thanks
Kumar


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 29, 2006 10:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Should ask tools questions in the tools forum. In anycase, the tools have a series of ant tasks which include a hbm2java sub-task. This can be run as build time or on as as needed basis. Check out the tools documentation for further information.


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.