-->
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: UNIQUE key mapping in Joined Subclasses.
PostPosted: Thu Feb 17, 2011 8:34 pm 
Newbie

Joined: Fri Nov 13, 2009 8:58 pm
Posts: 4
Hi guys, I am needing your assistance here, hope you can help me out.
According to this post https://forum.hibernate.org/viewtopic.php?p=2370666, the way to specify two columns as a unique key (the combination of this 2 columns must be unique) is to apply this mapping:

Code:
<properties name="subjectYearCombo_just_a_logical_name" unique="true">
        <property name="subject"/>
        <property name="year"/>
</properties>


The question is how can you specify this when you have a hierarchy situation using Joined sublcass and the atributes belong to 2 different objects:

Code:

<class name="User" table="Users abstract="true" polymorphism="implicit">
      <id name="id" type="long" column="id">
         <generator class="native" />
      </id>
      <property column="Name" name="Name" type="java.lang.String" not-null="true" />         
      
      <joined-subclass name="UserA" table="UsersA">
         <key column="id"/>
         <property column="JobAddress" name="jobAddress" not-null="true" />                      
      </joined-subclass>      
               
                <joined-subclass name="UserB" table="UsersB">
         <key column="id"/>
         <property column="HomeAddress" name="HomeAddress" not-null="true" />                      
      </joined-subclass>      
               
   </class>


I want to make the combination of User.Name AND UserA.jobAddress Unique, as well as the combination of User.Name AND UserB.HomeAddress also unique.

Is that clear enough?

Let me know if I need to explain myself a little better.
Many thanks in advance.

Regards!


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.