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)