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 Not Being Applied.
PostPosted: Wed Oct 06, 2010 6:47 am 
Newbie

Joined: Wed Oct 06, 2010 6:20 am
Posts: 2
We have been trying to annotate a two column unique constraint onto a table with no success.

The annotation looks like this:

@Entity
@Table( name="mytable",
uniqueConstraints={
@UniqueConstraint(
columnNames={ "MY_COLUMN_1",
"MY_COLUMN_2"
} )
} )
public class MyEntity ...etc

We have the following libraries in the build:
hibernate-core 3.5.6-Final
hibernate-jpa-2.0-api 1.0.0.Final
hibernate-annotations 3.5.6-Final
hibernate-c3p0 3.5.6-Final

And we're running against DB2.

We can build the database successfully from the hibernate annotations, the @Table annotation is being applied (we can use it to change the name of the table) but the unique constraint is never applied and no errors are reported.

It is clearly trying to apply the constraint because if we supply wrong column names an exception is reported.

Any ideas gratefully received.


Top
 Profile  
 
 Post subject: Re: Unique Constraints Not Being Applied.
PostPosted: Wed Oct 06, 2010 7:34 am 
Newbie

Joined: Wed Oct 06, 2010 6:20 am
Posts: 2
Hmm ... dogged persistence sometimes pays off. After we set the columns to non-nullable and updated to the versions above and probably did something else the whole thing started working.

May be there's a bug in there somewhere - it would be good to see an exception thrown whenever unique constraints cannot be applied.


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.