-->
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: mapping related objects NOT using PK's, FK's?
PostPosted: Wed Sep 29, 2004 5:46 pm 
Newbie

Joined: Fri Oct 03, 2003 8:44 am
Posts: 11
Hibernate version:
2.1.6


Is it possible to relate to objects without using their PK's/FK's in the mapping docs?

i.e.
(in this example, the two tables are related by the email address)

Code:
<class name="Account" table="account">
  <id name="id" column="user_id" type="java.lang.String">
    <generator class="assigned" />
  </id>
  <property name="emailAddress" column="email" type="java.lang.String"/>
</class>


<class name="User" table="user">
  <id name="id" type="java.lang.Integer" column="user_id" unsaved-value="null">
    <generator class="native" />
  </id>

  <property name="emailAddress" type="java.lang.String" column="email" />
  <!-- here's the relation I'd like to achieve -->
  <set name="accounts" table="account">
    <key column="email"/>
    <one-to-many class="Account"/>
  </set>
</class>


Is this somehow possible (I know the above mapping won't do it)?

Jon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 29, 2004 11:10 pm 
Beginner
Beginner

Joined: Mon May 03, 2004 1:25 pm
Posts: 31
we had a similar problem, and we solved it using Hibernate3 dynamic filters., but that only works if the actual primary key produces a super set of the set you want to produce.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:53 am 
Newbie

Joined: Sun Oct 17, 2004 4:43 am
Posts: 4
duggant wrote:
we had a similar problem, and we solved it using Hibernate3 dynamic filters., but that only works if the actual primary key produces a super set of the set you want to produce.



I guess you could also use the "were" within the set definition


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
yes but the where clause in collection is static (HB2)

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.