-->
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: Unique Constraint Through Hibernate Annotations
PostPosted: Thu Aug 28, 2008 9:19 am 
Newbie

Joined: Mon Mar 26, 2007 3:33 am
Posts: 18
Hi ,

I have a table with a primary key and a unique key. I create a hibernate bean as


@Entity
@Table(name = "TEST_TABLE")
public class Test{

@Id
@Column(name= "view_id")
private int viewId;

@Column(name = "viewname")
private String viewName;
}

When i do saveOrUpdate() i get duplicate rows for same viewName. But my viewName should be unique?

Is there any thing wrong that i am doing?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 3:46 pm 
Newbie

Joined: Sat Aug 02, 2008 12:09 pm
Posts: 12
Set unique to true.

Code:
@Column(name = "viewname", unique = true)
private String viewName;
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 3:48 pm 
Newbie

Joined: Sat Aug 02, 2008 12:09 pm
Posts: 12
Set unique to true.

Code:
@Column(name = "viewname", unique = true)
private String viewName;
}


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.