[ rubbish-db ]

ソース

RubbishDatabase dbh = new RubbishDatabase(new HsqldbExceptionFactory());
dbh.setLogging(true);

dbh.connect("jdbc:hsqldb:hsql://localhost", "sa", "");

Book book = new Book();
book.setPublisher("07");
book.setId("000");
book.setTitle("獲九里伏");
book.setAuthor("愛微意笑");
book.setIssue_date(null);
book.setUpdate_date(new Date());
book.setCreate_date(new Date());

try {
    dbh.insert(book);
} catch (SQLReferentialException e) {
    System.out.println(e);
}

try {
    dbh.update("DELETE FROM PUBLISHER");
} catch (SQLReferentialException e) {
    System.out.println(e);
}

dbh.rollback();
dbh.disconnect();

結果

connect database 'url=jdbc:hsqldb:hsql://localhost, user=sa, password='.
'INSERT INTO BOOK (AUTHOR, CREATE_DATE, ID, ISSUE_DATE, PUBLISHER, TITLE, UPDATE_DATE) VALUES (?, ?, ?, ?, ?, ?, ?) [愛微意笑, 2005-09-11 11:04:44.730, 000, null, 07, 獲九里伏, 2005-09-11 11:04:44.730]'
rubbish.db.exception.SQLReferentialException: java.sql.SQLException: Integrity constraint violation - no parent FK_PUBLISHER table: PUBLISHER in statement [INSERT INTO BOOK (AUTHOR, CREATE_DATE, ID, ISSUE_DATE, PUBLISHER, TITLE, UPDATE_DATE) VALUES (?, ?, ?, ?, ?, ?, ?)] (error code=-177, SQLState=23000, SQL='INSERT INTO BOOK (AUTHOR, CREATE_DATE, ID, ISSUE_DATE, PUBLISHER, TITLE, UPDATE_DATE) VALUES (?, ?, ?, ?, ?, ?, ?) [愛微意笑, 2005-09-11 11:04:44.730, 000, null, 07, 獲九里伏, 2005-09-11 11:04:44.730]')
'DELETE FROM PUBLISHER'
rubbish.db.exception.SQLReferentialException: java.sql.SQLException: Integrity constraint violation FK_PUBLISHER table: BOOK in statement [DELETE FROM PUBLISHER] (error code=-8, SQLState=23000, SQL='DELETE FROM PUBLISHER')
rollback transaction.
disconnect database.