-->
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 Constraints
PostPosted: Thu Jan 12, 2006 9:22 am 
Beginner
Beginner

Joined: Sun Dec 05, 2004 10:25 am
Posts: 23
I am using Hibernate 3.0 and was wondering if Hibernate had support for applying a contraint on multiple columns/attributes?

In other works I have a table that has 4 columns an id and the other 3 have a unique constraint in the database. I am wondering if Hibernate could handle this constraint for me in Java?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 12:33 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 9:52 am
Posts: 52
Location: Zurich
I think your are looking for something like this:

Code:
  <class name="eg.TTest" table="TTest">
    <id name="id" column="id" type="long">
      <generator class="native"></generator>
    </id>
    <properties name="group"  unique="true">
      <property name="one"/>
      <property name="two"/>
      <property name="three"/>
    </properties>

  </class>


which creates:

Code:
create table TTest (
    id numeric(19,0) identity not null,
    one varchar(255) null,
    two varchar(255) null,
    three varchar(255) null,
    primary key (id),
    unique (one, two, three)
)


Urs


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.