You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@empire-db.apache.org by Jon Frias <fr...@gmail.com> on 2013/10/08 08:55:47 UTC

empire db 2.4.1: running scripts and autoGenerated fields

Hi all,

I have the following problem and I don't know if this is normal or I am
doing something wrong. Can anybody help?

Once I have a database schema created I want to initialize the first
registers. To do this, I am using an script (I load it and run it). Until
now everything works fine (the database schema and the first registers are
created correctly).

The problem comes after this.

All the autoGenerated fields (id fields) are not working properly and they
don't take into account the registers created by the script, so every time
I create a new record after this using DBRecord class, etc. an error
message is triggered saying that the "unique key constraint is violated".

I don't know if I am doing something wrong or if this is normal and I have
to avoid using the script. Because if I initialize the first registers by
code (using DBRecord class -- the same registers information), everything
works fine.

The source code is the following:

//To create the database schema
DBSQLScript script = new DBSQLScript();
db.getCreateDDLScript(driver, script);
try{
      script.run(driver, conn, false);
      db.commit();
 }

//To execute the script to initialize the database information
DBSQLScript script = new DBSQLScript();
script.addStmt(sql);
try{
     script.run(driver, conn, false);
     db.commit(conn);
}

I have also tried the script step with this code but the result obtained
was the same

driver.executeSQL(sql, null, conn, null); //driver is the DatabaseDriver
instance


Can anybody tell me if I am doing something wrong?

Thanks a lot for your help.
Best regards,

Jon