-->
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: Component as collection?
PostPosted: Tue Jan 18, 2005 6:01 pm 
Newbie

Joined: Tue Jan 18, 2005 5:20 pm
Posts: 2
Location: Fort Worth, TX
I'm mapping an object to two data sources. Data source one is normalized, so:

Code:
===== PERSON ======
ID |    NAME
-------------------
  1 |     Joe


==== PERSON_PHONE ====
PERSON_ID | PHONE_ID
----------------------
  1 |       1


====== PHONE ======
ID | PHONE_NUMBER
-------------------
  1 | 111-111-1111


Data source two is not normalized...

Code:

===== PERSON ==============
ID | NAME |  PHONE_NUMBER
---------------------------
  1 |  Joe  | 111-111-1111



I'd like to map a Person object with a property called phoneNumbers, which is a set of PhoneNumber ojbects:

Code:
class Person {
  ...
  private Set phoneNumbers;
  public void setPhoneNumbers(Set set) { ... }
  public Set getPhoneNumbers { ... }
  ...
}


I know how to do this with the normalized schema:

Code:
<class name="Person" table="PERSON">
  ...
  <set name="phoneNumbers" table="PERSON_PHONE">
    <key column="PERSON_ID"/>
    <many-to-many column="PHONE_ID" class="Phone"/>
  </set>
  ...
</class>



How do I map PHONE_NUMBER as a Set with with the denormalized schema?



Hibernate version: 2.1.7c


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 6:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
There is no "set" in the second example, every person has only one phone number ... I don't get your problem


Top
 Profile  
 
 Post subject: Re: Component as collection?
PostPosted: Tue Jan 18, 2005 7:02 pm 
Newbie

Joined: Tue Jan 18, 2005 5:20 pm
Posts: 2
Location: Fort Worth, TX
As I wrote:

jt2190 wrote:
I'm mapping an object to two data sources.


The property of that object is a java.util.Set. Yes, it is a one-to-one mapping in the second case, but I'd still like to have a Set, only with one object. My question: is this possible?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You could probably implement a custom UserType or something, but that would rather be a hack and only work if there are no further associations from the PhoneNumber objects.


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.