Derby:同一事件的第二个触发器导致ArrayIndexOutOfBoundsException

时间:2014-12-18 15:20:50

标签: java derby triggers

我试图在Derby数据库中类似Oracle模式以进行测试。 该模式还应包括同一个表的2个触发器。

我将它们定义如下:

create trigger myTrigger
    after update on myTable
    referencing old as oldRow new as newRow
    for each row MODE DB2SQL
        delete from otherTable where otherTable.id=newRow.id and newRow.usable is not null and newRow.usable='1' and oldRow.usable='0';

create trigger myTrigger2
    after update on myTable
    referencing old as oldRow new as newRow
    for each row MODE DB2SQL
        update myTable set counter=0 where myTable.id=newRow.id and newRow.usable is not null and newRow.usable='1' and oldRow.usable='0';

当我只定义其中一个时,它工作正常,但是一旦我同时定义了两个,我就会收到这个错误:

[...]
Caused by: java.sql.SQLException: Java exception: '-1: java.lang.ArrayIndexOutOfBoundsException'.
    at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
    at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
    at de.bmw.database.DerbySqlConnector.sql(DerbySqlConnector.java:287)
    ... 27 more
Caused by: java.sql.SQLException: Java exception: '-1: java.lang.ArrayIndexOutOfBoundsException'.
    at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
    ... 38 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:400)
    at java.util.ArrayList.remove(ArrayList.java:477)
    at org.apache.derby.iapi.services.context.ContextManager.popContext(Unknown Source)
    at org.apache.derby.iapi.services.context.ContextImpl.popMe(Unknown Source)
    at org.apache.derby.impl.store.access.RAMTransaction.destroy(Unknown Source)
    at org.apache.derby.iapi.sql.dictionary.SPSDescriptor.getPreparedStatement(Unknown Source)
    at org.apache.derby.iapi.sql.dictionary.SPSDescriptor.getPreparedStatement(Unknown Source)
    at org.apache.derby.impl.sql.execute.GenericTriggerExecutor.executeSPS(Unknown Source)
    at org.apache.derby.impl.sql.execute.RowTriggerExecutor.fireTrigger(Unknown Source)
    at org.apache.derby.impl.sql.execute.TriggerEventActivator.notifyEvent(Unknown Source)
    at org.apache.derby.impl.sql.execute.UpdateResultSet.fireAfterTriggers(Unknown Source)
    at org.apache.derby.impl.sql.execute.UpdateResultSet.open(Unknown Source)
    at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
    at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
    ... 31 more

有人知道触发器定义有什么问题吗?

0 个答案:

没有答案