-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to create UNIQUE Constraint with DISCRIMINATOR column ?
PostPosted: Wed Aug 08, 2007 2:13 pm 
Newbie

Joined: Fri Jul 27, 2007 5:48 pm
Posts: 4
I have "Table per class hierarchy" mapping using discriminator column.

I need to create unique constraint that should consists of two columns: a property column and discrimonator column (unique property for given class).

Does it possible to do this via hibernate mapping, or I should write custom ddl-sqcript?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 4:50 pm 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Doesn't look like its possible. According to the docs you can create unique constraints over multiple _properties_ using <properties> and property-ref but <properties> doesn't allow <discriminator>.

You can include custom ddl in your mapping files however, through the <database-object> element:
e.g. (from docs)
Code:
<database-object>
        <create>CREATE TRIGGER my_trigger ...</create>
        <drop>DROP TRIGGER my_trigger</drop>
</database-object>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 5:07 am 
Newbie

Joined: Fri Jul 27, 2007 5:48 pm
Posts: 4
thatmikewilliams wrote:
Doesn't look like its possible.
You can include custom ddl in your mapping files however, through the <database-object> element:


Thanks for relpy. Will try <database-object>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.