-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping refers to an Id, but does not show up in java object
PostPosted: Thu Jan 21, 2010 12:36 pm 
Newbie

Joined: Wed Sep 10, 2008 2:31 pm
Posts: 16
I have 2 example classes below that are linked by a one-to-one or a many-to-one (would like to know if its possible for both).

I just want to know is it possible to leave out personId from my hair class and just have it referenced in the mapping (somewhat in a way of a discriminator). I don't think the hair object should care who it is attached to, it should just know about itself.

Java
Code:
class Person {
      String personId;
      Hair hair;
}

class Hair {
       String personId;
       String color;
       String type;
}

Hibernate
Code:
   <class name="Person" table="PersonTable">
      <id name="personId" column="ID" type="string" />
      <one-to-one name="hair" entity-name="Hair"/>   
   </class>

   <class name="Hair" table="HairTable" entity-name="Hair">
      <id name="personId" column="ID" type="string" />
      <property name="color" column="COLOR" type="string" />
      <property name="type" column="TYPE" type="string" />
   </class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.