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!