-->
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: Disable unique constraint
PostPosted: Tue Mar 20, 2007 4:27 am 
Newbie

Joined: Thu Dec 14, 2006 11:17 am
Posts: 9
Hello,

I need do disable an unique constraints for the time of an update.
Consider the following example:

Code:
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "personID", "fieldID" }))
public class SomeMappingTable {
  private Integer personID;
  private Integer fieldID;
  // ...
}


Ok, assume I have to entries in it
Code:
fieldID: 1 ("Mathematics")
fieldID: 2 ("English")


The user has 2 combos: in the first Mathematics is selected, in the second one English.
Now, if the users switches the values (Mathematics -> English and English -> Mathematics) the unique constraint is violated because after the first update the table would contain English twice.

So, the only way how to solve the problem is to disable the unique constraint for the time of the update. Maybe somebody knows another solution.

Thanks a lot,
Kasperl


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 6:53 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The whole point of database constraints is that they can _not_ be disabled by a (buggy) application.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 7:20 am 
Newbie

Joined: Thu Dec 14, 2006 11:17 am
Posts: 9
Do you have any other ideas how to solve my problem?


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.