-->
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.  [ 2 posts ] 
Author Message
 Post subject: Unique constraint for multiple columns
PostPosted: Thu Aug 10, 2006 11:53 am 
Beginner
Beginner

Joined: Tue Aug 08, 2006 11:53 am
Posts: 37
Hi all,

I want to add a unique constraint on multiple columns. Can someone please let me know how to do specify this in the mapping document (if at all we can). Also, how does hibernate report the unqiue constraint violation? Does it give the name of the constraint that has been violated?

I want the unique constraint to be on "csaType" and "equipmentDeliverDate" columns combined!

Thank you in advacne!

Hibernate version: 3.x

Mapping documents:

<hibernate-mapping>

<class name="Csa" table="CSA">

<id name="id" column="CSA_ID">
<generator class="native"/>
</id>
<property name="csaType" column="CSA_TYPE" type="string" not-null="true" length="2"/>
<property name="detailedCsaType" column="CSA_TYPE_DETAIL" type="string" not-null="true" length="20"/>
<property name="startingSmu" column="STARTING_SMU" type="double" not-null="true" precision="10" scale="2"/>
<property name="smuIndicator" column="SMU_INDICATOR" type="string" not-null="true" length="2"/>
<property name="equipmentDeliveryDate" column="EQUIP_DELIVERY_DATE" type="date" not-null="true" />
<property name="csaStartDate" column="CSA_START_DATE" type="date" not-null="true" />
<property name="csaEndDate" column="CSA_END_DATE" type="date" not-null="true" />

</class>

</hibernate-mapping>

Name and version of the database you are using:Oracle 10g


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 2:24 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
You can nest those two properties in the <natural-id> tag. See http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#mapping-declaration-naturalid

_________________
nathan


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