Autoincrement field that is not the primary key

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Autoincrement field that is not the primary key

MSSQL Database, DBUnit 2.4.7

java.sql.SQLException: Cannot update identity column

Table Structure:
cam_id int (this is the autoincrement field, but is not the primary key)
client_id int
admin_id int
role_id int
sub_client_flag bit
user_stamp int

The primary key is not cam_id. The primary key is client_id, admin_id and role_id.

    IDatabaseTester databaseTester = new PropertiesBasedJdbcDatabaseTester();
        IDatabaseConnection connection = databaseTester.getConnection();
        DatabaseConfig config = connection.getConfig();
config.setProperty(DatabaseConfig.PROPERTY_PRIMARY_KEY_FILTER, InsertIdentityOperation.IDENTITY_FILTER_EXTENDED);
        XmlDataSet dataSet = new XmlDataSet(new FileInputStream(file));        

When I change the primary key to be the cam_id field, this code will work and I get the row I expect in the database. What am I supposed to change to allow DBUnit to update a MSSQL database with an autoincrement field that is not a primary key field?

My first day working with DBUnit... Any help is appreciated... Thanks...