-->
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: One-to-one mapping
PostPosted: Fri Oct 10, 2003 12:23 pm 
Regular
Regular

Joined: Wed Sep 10, 2003 7:09 am
Posts: 63
Hi,

I am trying to map a one-to-one relation between two classes, but i want to associate a id with a not id column.

these are my two classes:

<class
name="Text"
table="Text">
<id
name="chvp"
column="chvp"
type="integer">
<generator class="identity"/>
</id>
</class>

<class
name="TipoDeContentor"
table="TipoDeContentor">
<id
name="chvp"
column="chvp"
type="integer">
<generator class="foreign">
<param name="property">descricao</param>
</generator>
</id>
<one-to-one
name="descricao"
class="Text"
cascade="all"
constrained="true"/>
</class>


I am trying that TipoDeContentor.descricao (not id) be associated with Text.chvp (id). Is that possible?

When i store a TipoDeContentor object, there are no exceptions, and both classes are stored, but TipoDeContentor.descricao has no value and both IDs have the same key value.

What am i doing wrong?

Thanks in advance,
Joao Rangel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 11, 2003 7:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
When using one-to-one where the primary keys are not the join then you need to define in the mapping the property reference. This is only in 2.1 and is documented in the 2.1 documentation.


Top
 Profile  
 
 Post subject: Hibernate 2.1 documentation
PostPosted: Mon Oct 13, 2003 5:07 am 
Regular
Regular

Joined: Wed Sep 10, 2003 7:09 am
Posts: 63
Where can i find hibernate 2.1 documentation?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 5:12 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
In the Hibernate 2.1 package.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.