-->
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: SchemaUpdate with SQL SERVER
PostPosted: Mon Mar 20, 2006 8:10 am 
Beginner
Beginner

Joined: Tue Apr 05, 2005 12:09 pm
Posts: 48
Location: Slovakia (SK), Košice (KE)
Hibernate version: 3.1
Name and version of the database you are using: SQL Server 2000 sp 3a

hi

SchemaUpdate(cfg).execute(false); will throw an exception if it is adding a foreign key or unique column to the table. It is caused because SQL SERVER doesn't allow to add multiple NULL values to the same column if it is defined as UNIQUE or PRIMARY KEY :-(

My question is - how can I perform such database updates? My steps would be - 1. add new column to a table, 2. assign values to that column, 3. add constraint (PK/UNIQUE) to that column. But hibernate performs step 1 and 3 together.

Thanks in advance.

Exception example:
Code:
2006-03-20 12:15:53,640 WARN  org.springframework.orm.hibernate3.LocalSessionFactoryBean - Unsuccessful schema statement: alter table KFE_BUSINESS_CASE add OK_BTN_MSG_KEY_ID int unique
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]CREATE UNIQUE INDEX terminated because a duplicate key was found for index ID 2. Most significant primary key is '<NULL>'.
   at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
   at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
   at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
   at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
   at com.microsoft.jdbc.base.BaseStatement.executeUpdate(Unknown Source)

_________________
Martin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
first: schemaupdate cannot/does not handle all conceivable update paths (there are infiinte many)

second: if you can see a way of doing it portable without too much voodo then submit a fix/patch. thank you.

_________________
Max
Don't forget to rate


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.