-->
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.  [ 3 posts ] 
Author Message
 Post subject: simple mapping problem
PostPosted: Sat Aug 06, 2005 2:58 pm 
Newbie

Joined: Mon Feb 28, 2005 11:09 am
Posts: 7
Hi,

i´m new in Hibernate and have some problems to get it ;-( I tried to map this simple modell to my database (for now, adress should be a 1to1 relation, not a collection, Einrichtung is a german word, you may translate it with company):
Image<br>
This is the database view:
Image
I played with the mapping, but it doesn´t work. Can anyone help with the the correct mapping ?

Hibernate version: 3

Code:
<hibernate-mapping>
<class name="de.hannit.fsch.benutzerverwaltung.Einrichtung" table="Einrichtung">
   <id name="id" column="id">
      <generator class="identity" />
   </id>
<property name="name" type="string" column="name" />
<many-to-one    name="adresse"
         class="de.hannit.fsch.benutzerverwaltung.Adresse"
         column="adresseID" />
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: simple mapping problem
PostPosted: Sat Aug 06, 2005 6:23 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
horstbrack wrote:
Hi,

i´m new in Hibernate and have some problems to get it ;-( I tried to map this simple modell to my database (for now, adress should be a 1to1 relation, not a collection, Einrichtung is a german word, you may translate it with company):
Image<br>
This is the database view:
Image
I played with the mapping, but it doesn´t work. Can anyone help with the the correct mapping ?

Hibernate version: 3

Code:
<hibernate-mapping>
<class name="de.hannit.fsch.benutzerverwaltung.Einrichtung" table="Einrichtung">
   <id name="id" column="id">
      <generator class="identity" />
   </id>
<property name="name" type="string" column="name" />
<many-to-one    name="adresse"
         class="de.hannit.fsch.benutzerverwaltung.Adresse"
         column="adresseID" />
</class>
</hibernate-mapping>


Can you show your code and what exception, if any, you're getting ?

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 06, 2005 8:19 pm 
Beginner
Beginner

Joined: Tue Jun 28, 2005 8:51 pm
Posts: 20
Location: Bergamo, Italy
For a 1 to 1 association you can use Components that is the best way but if you need 2 table distinct you have to map the two Pojo Classes.
Look at my file where there is 1 to 1 association and try to understand from them, remember you have to map 2 classes!
This method use a new column in database for

, bye :)

<class
name="com.full.hibernate.model.Fuzzyattribute"
table="FUZZYATTRIBUTES"
>
<!-- Common id property. -->
<id name="id"
type="long"
column="FUZZYATTRIBUTES_ID"
unsaved-value="null">
<generator class="native" />
</id>
....
<property
name="name"
type="java.lang.String"
length="50"
unique="true">
<column name="NAME" unique-key="uk_object_name"/>
</property>




<!-1 to 1-->
<one-to-one name="attribute"
class="com.full.hibernate.model.Attribute"
property-ref="fuzzyattribute"/>


<class
name="com.full.hibernate.model.Fuzzyset"
table="FUZZYSETS"
>

<!-- Common id property. -->
<id name="id"
type="long"
column="FUZZYSET_ID"
unsaved-value="null">
<generator class="native" />
</id>


<property
name="name"
type="java.lang.String"
not-null="true"
length="50">
<column name="NAME" unique-key="uk_object_name"/>
</property>

....

<many-to-one name="fuzzyattribute"
class="com.full.hibernate.model.Fuzzyattribute">
<column name="FUZZYSET_REF" />
</many-to-one>


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