You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@empire-db.apache.org by Joel Becker <jo...@gmail.com> on 2012/07/25 23:26:53 UTC

Error creating FKs on HSQLDB with DBSQLScript.run

Hi,

I'm getting the following error when using DBSQLScript.run() to create an
HSQLDB database:

2012-07-25 15:22:42,471 [main] ERROR org.apache.empire.db.DBSQLScript  -
java.sql.SQLException: Primary or unique constraint required on main table:
VOTERS in statement [-- creating foreign key constraint
absentee_ballo_registrant_i_FK --
ALTER TABLE absentee_ballots ADD CONSTRAINT absentee_ballo_registrant_i_FK
FOREIGN KEY (registrant_id) REFERENCES voters (id)]
java.sql.SQLException: Primary or unique constraint required on main table:
VOTERS in statement [-- creating foreign key constraint
absentee_ballo_registrant_i_FK --
ALTER TABLE absentee_ballots ADD CONSTRAINT absentee_ballo_registrant_i_FK
FOREIGN KEY (registrant_id) REFERENCES voters (id)]
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
 at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.executeUpdate(Unknown Source)
 at
org.apache.empire.db.DBDatabaseDriver.executeSQL(DBDatabaseDriver.java:552)
at org.apache.empire.db.DBSQLScript.run(DBSQLScript.java:120)


Is the script being generated incorrectly?
This stackoverflow entry says it should be formatted differently:
http://stackoverflow.com/questions/10031613/hsql-error-when-attempting-to-create-foreign-key-constraint

Thanks,
Joel

Re: Error creating FKs on HSQLDB with DBSQLScript.run

Posted by Francis De Brabandere <fr...@gmail.com>.
Hi Joel,

Would you mind creating an issue for this one?
https://issues.apache.org/jira/browse/EMPIREDB

I'll make sure we set up a unit test + fix this

Cheers,
Francis

On 25 July 2012 23:26, Joel Becker <jo...@gmail.com> wrote:
> Hi,
>
> I'm getting the following error when using DBSQLScript.run() to create an
> HSQLDB database:
>
> 2012-07-25 15:22:42,471 [main] ERROR org.apache.empire.db.DBSQLScript  -
> java.sql.SQLException: Primary or unique constraint required on main table:
> VOTERS in statement [-- creating foreign key constraint
> absentee_ballo_registrant_i_FK --
> ALTER TABLE absentee_ballots ADD CONSTRAINT absentee_ballo_registrant_i_FK
> FOREIGN KEY (registrant_id) REFERENCES voters (id)]
> java.sql.SQLException: Primary or unique constraint required on main table:
> VOTERS in statement [-- creating foreign key constraint
> absentee_ballo_registrant_i_FK --
> ALTER TABLE absentee_ballots ADD CONSTRAINT absentee_ballo_registrant_i_FK
> FOREIGN KEY (registrant_id) REFERENCES voters (id)]
> at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
> at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
> at org.hsqldb.jdbc.jdbcStatement.executeUpdate(Unknown Source)
> at
> org.apache.empire.db.DBDatabaseDriver.executeSQL(DBDatabaseDriver.java:552)
> at org.apache.empire.db.DBSQLScript.run(DBSQLScript.java:120)
>
>
> Is the script being generated incorrectly?
> This stackoverflow entry says it should be formatted differently:
> http://stackoverflow.com/questions/10031613/hsql-error-when-attempting-to-create-foreign-key-constraint
>
> Thanks,
> Joel
>