-->
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: unique-key constraint and inherited properties
PostPosted: Wed Jul 27, 2005 11:42 am 
Newbie

Joined: Wed Jul 27, 2005 11:02 am
Posts: 3
Hi everybody,

For our application, we need to define a unique-key constraint that applies
on several columns of a table.
We have a class inheritance using the table per concrete class strategy (with the union-subclass tag into the mapping file).

After several tries, it seems impossible to have a unique-key constraint on several properties defined at different inheritance levels.

Simplified mapping file:

<class name="SuperClass" abstract="true">

<property name="SuperProperty"/>

<union-subclass name="SubCass">

<property name="SubProperty"/>

</union-subclass>

</class>


So, how to define a unique-key constraint on SuperProperty AND SubProperty ?

Thanks for your help.

J.P.

Hibernate version:3.0.5
Database: Oracle 9


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 12:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
<property ... unique-key="foo"/>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 1:09 pm 
Newbie

Joined: Wed Jul 27, 2005 11:02 am
Posts: 3
Hi Gavin, thanks for your reply !

Unfortunately, we had already tried the unique-key attribute. It seems not to work in our situation.

The SQL for table creation looks like:

create table SUBCLASS (
....
SUPERPROPERTY varchar2(255),
SUBPROPERTY varchar2(255),
....
unique (SUBPROPERTY)
)


But we want the constraint on the two columns like this:
unique (SUBPROPERTY,SUPERPROPERTY)

Grouping several properties in a unique-key constraint seems to work only if all the properties are defined in the same concrete class...

J.Ph.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 1:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Submit it to JIRA.


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.