-->
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: make combination of multiple columns unique using JPA
PostPosted: Tue Apr 07, 2009 3:55 am 
Newbie

Joined: Wed Apr 01, 2009 11:06 am
Posts: 5
I'm using Hibernate as a JPA implementation and I didn't manage to make a comination of multiple columns unique.

Code:
@Entity
@Table(name = "EXAMPLE")
public class Test implements Serializable{

   private static final long serialVersionUID = -7104819378300361520L;

   @Id
   @GeneratedValue
   @Column(name = "id")
   private Long id = null;

   @Column(name = "cond1", length = 30, nullable = false)
   private boolean cond1;

   @Column(name = "cond2", nullable = false)
   private boolean cond2;
   
}


In a handwritten mysql ddl statement it would be something like
create table( id int auto_increment, primary key(id), cond1 boolean not null, cond2 boolean not null, unique(cond1,cond2));

thx in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 07, 2009 5:11 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
Please refer to following link.
http://lia.deis.unibo.it/Courses/Tecnol ... raint.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 07, 2009 7:23 am 
Newbie

Joined: Wed Apr 01, 2009 11:06 am
Posts: 5
it worked, thx


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.