-->
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.  [ 7 posts ] 
Author Message
 Post subject: Error Mapping Relation many-to-one
PostPosted: Mon Mar 26, 2007 10:57 am 
Newbie

Joined: Mon Mar 26, 2007 10:48 am
Posts: 13
Hi, my problem is following:

i have 2 .xml files:

Code:
<hibernate-mapping>
<class name="mypackage.Hospital" table="hospital">
<id name="id" column="id" type="java.lang.Integer">
<generator class="increment"/>
</id>
<property name="bez" column="bez" type="java.lang.String" />
<property name="plz" column="plz" type="java.lang.String" />
<set name="patienten" cascade="all" lazy="true">
      <key column="hospital"/>
      <one-to-many class="mypackage.Patient"/>
</set>
</class>
</hibernate-mapping>


and this one:

Code:
<hibernate-mapping>
<class name="mypackage.Patient" table="patient">
<id name="sv_nr" column="sv_nr" type="java.lang.Integer">
</id>
<property name="plz" column="plz" type="java.lang.String" />
<property name="email" column="email" type="java.lang.String" />
<property name="hospital" column="hospital" type="mypackage.Hospital" />
   <many-to-one name="hospital" column="hospital" class="mypackage.Hospital"/>
</class>
</hibernate-mapping>


the relations is one patient could only be in one hospital - but one hospital could contain of a lot of patient... hospital - patient ==> many-to-one

My Error:

Code:
Could not initialize the Hibernate configuration
null
org.hibernate.MappingException: Duplicate property mapping of hospital found in mypackage.Patient


i don't know if my mappping is right:/

i hope this was enough information -

thx 4 help ..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 1:27 pm 
Newbie

Joined: Wed Jul 14, 2004 5:37 pm
Posts: 5
try this

Code:
<hibernate-mapping>
<class name="mypackage.Patient" table="patient">
<id name="sv_nr" column="sv_nr" type="java.lang.Integer">
</id>
<property name="plz" column="plz" type="java.lang.String" />
<property name="email" column="email" type="java.lang.String" />

   <many-to-one name="hospital" column="hospital" class="mypackage.Hospital"/>
</class>
</hibernate-mapping>


delete the line
<property name="hospital" column="hospital" type="mypackage.Hospital" />


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 4:10 pm 
Newbie

Joined: Mon Mar 26, 2007 10:48 am
Posts: 13
i deleted this one but now i got the error:

Code:
hospital is not mapped [from hospital]
null
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException

....

thx in avadance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 4:33 pm 
Newbie

Joined: Wed Jul 14, 2004 5:37 pm
Posts: 5
Please paste the hibernate startup log, and the HQL you are using.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 4:40 pm 
Newbie

Joined: Wed Jul 14, 2004 5:37 pm
Posts: 5
use Hospital in the HQL instead of hospital!
It's not the same.

Good luck


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 5:10 pm 
Newbie

Joined: Mon Mar 26, 2007 10:48 am
Posts: 13
yeah - it works - thx very much!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 6:46 pm 
Newbie

Joined: Wed Jul 14, 2004 5:37 pm
Posts: 5
Good!
Please rate my post to get one credit.

Thanks.


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