This content has been marked as final.
Show 3 replies
-
1. Re: Annotation @Column(unique=true) does not prevent duplicate insertions
quaidbrown Jul 18, 2008 4:38 PM (in response to pdhaigh)Not sure, but I use the @NaturalId annotation for this.
-
2. Re: Annotation @Column(unique=true) does not prevent duplicate insertions
francof Jul 18, 2008 4:44 PM (in response to pdhaigh)I am a newbie to Seam, Hibernate ... , so I might be wrong.
unique=true is only needed if you intend to generate your schema from your entity class.
See this post http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073319#4073319
I went with approach D since my unique column is my surrogate key.
-
3. Re: Annotation @Column(unique=true) does not prevent duplicate insertions
quaidbrown Jul 18, 2008 5:02 PM (in response to pdhaigh)Ya, I think the constraint on that field is only put in place if you let it create the tables for you when you start up, by specifying create-drop or something similar in persistence.xml.
I don't think it will add a constraint after the table already exists. So that's something to try.