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.  [ 9 posts ] 
Author Message
 Post subject: hbm2java difference in Hibernate 2 and Hibernate 3
PostPosted: Sat May 14, 2005 6:17 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
Hi,

I have a persistent class ObjectA which has a one-to-one reference to ObjectB defined in the ObjectA's mapping file as follows:

<many-to-one name="objectB"
class="ObjectB"
column="OBJECT_B_ID"
cascade="all"
unique="true"/>

I use hbm2java to generate source code for the two classes.

If I use Hibernate 2.x, everthying goes beautifully: two java files generated.

If I use Hibernate 3.0.3, I always get the error message as follows:
org.hibernate.MappingException: An association from the table OBJECT_A refers to an unmapped class: OBJEDT_B.

I use an Ant build script. Except for changes from net.sf to org for net.sf.hibernate.tool.hbm2java.Hbm2JavaTask and using H3 jars (hibernate and tools), I did make any other changes to the script.

I also notice the only source java file generated in case of Hibernate 3, ObjectB.java, does not have accessor methods for its id.

I searched the 3.0.3 reference and this forum but failed to find any userful information. I cannot figure it out.

Can somebody shed light on this? How to fix it? How to have id's acccessor methods generated?

Thanks and regards,
Pete


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 14, 2005 6:56 pm 
Regular
Regular

Joined: Mon Apr 25, 2005 9:22 am
Posts: 62
Location: Bucharest/Romania
Is your ObjectB defined in its own mapping file? (for table OBJECT_B i suppose). Is it included in the fileset to be processed by the hbm2java task?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 14, 2005 7:06 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
Yes. Here is the target in the ant script. As I said, I ran the same script
for H2 and had no problem at all. Only H3 produced the problem I have.


<target name="codegen" description="Generate Java source from the O/R mapping files">
<taskdef name="hbm2java" classname="org.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="class.path" />
<mkdir dir="${codegen.dir}/>
<hbm2java output="${codegen.dir}" classpathref="class.path">
<fileset dir="${src.model.dir}">
<patternset id="mapping.files">
<include name="ObjectB.hbm.xml"/>
<include name="ObjectA.hbm.xml"/>
</patternset>
</fileset>
</hbm2java>
</target>


Thanks,
Pete


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2005 1:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
already fixed in cvs.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2005 2:17 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
Max,

Thanks for your info.

I got all source from

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/hibernate checkout -P Hibernate3

I still got the same error.

Then I got all source from

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/hibernate checkout -P HibernateExt

and rebuilt the tools and found out that there is even no a class called

org.hibernate.tool.hbm2java.Hbm2JavaTask

in the source.

Did I miss something?

Thank you so much for your help.

Pete


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2005 3:06 pm 
Regular
Regular

Joined: Mon Feb 23, 2004 10:42 pm
Posts: 102
Location: Washington DC
Sourceforge has an delay on the anonymous cvs....it can take 5-6 hrs to show up.

_________________
Matt Veitas


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2005 4:28 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
Matt,

Thanks for your input.

You sure the fix mentioned by Max was put into anonymous CVS only today?
I have checked out the source 3 times and am still having
the problem. (I chcked it out 10 minutes ago)

I am puzzled. Did you experience the same problem or not?
Could you do a test to verify the problem?

Regards,
Pete


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2005 5:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are referring to an old and deleted class.

read for uptodate info http://cvs.sourceforge.net/viewcvs.py/* ... ml?rev=1.4

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2005 6:24 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
Max,

Thanks so much for the info. The problem is gone.

Regards,
Pete


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