-->
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.  [ 4 posts ] 
Author Message
 Post subject: Having a problem with a simple one-to-one association
PostPosted: Tue Jul 22, 2008 2:16 pm 
Newbie

Joined: Wed Jul 09, 2008 4:12 pm
Posts: 3
I'm trying to use the Hibernate ANT tasks to generate the model java compoents from my HBM files, per this link http://www.hibernate.org/hib_docs/refer ... tional-121 and its not working.

Hibernate version: 3.2.6 ga

Mapping documents:
User.hbm.xml
<hibernate-mapping>
<class name="com.model.User" table="USERS">
<id name="id" type="int" column="USER_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
</class>
</hibernate-mapping>

UserDetail.hbm.xml
<hibernate-mapping>
<class name="com.model.UserDetail" table="USER_DETAILS">
<id name="userDetailsId" type="int" column="USER_ID">
<generator class="foreign">
<param name="property">user</param>
</generator>
</id>
<one-to-one name="User" constrained="true"/>
</class>
</hibernate-mapping>

Full stack trace of any exception that occurs:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/model/UserDetails.hbm.xml
[hibernatetool] org.hibernate.MappingException: class com.model.UserDetail not found while looking for property: User
[hibernatetool] java.lang.ClassNotFoundException: com.model.UserDetail
[hibernatetool] A class were not found in the classpath of the Ant task.
[hibernatetool] Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.

BUILD FAILED
C:\workspace_jee\MyApp\build.xml:118: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/adobe/UserDetails.hbm.xml

Name and version of the database you are using:
HSQL


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 5:14 pm 
Beginner
Beginner

Joined: Fri Aug 05, 2005 3:36 am
Posts: 28
The message says it cannot find this class:

com.model.UserDetail

Are you certain that you've got the right package, and that it is available from the class path you passing to the hbm2java task?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 22, 2008 6:04 pm 
Newbie

Joined: Wed Jul 09, 2008 4:12 pm
Posts: 3
That's what seems so weird to me. the task should be creating that class, but I believe it's failing... I'm just not sure why. I think I emulated the link I have in the o.p. exactly.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 5:05 pm 
Newbie

Joined: Thu Mar 17, 2005 2:06 pm
Posts: 12
Chachany,

Wouldn't it be easier to write your java objects first and then have the hbm's generated from those? I feel this way because that's a lot easier than writing the hbm xml files. This tool will do that, and can also write your sql too: http://www.javatosql.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.