1.0rc2 - INSERT not activating Oracle Sequences for primary key generation, NULL instead.

From: Mike Kienenberger (mkienen..laska.net)
Date: Tue Sep 09 2003 - 22:29:01 EDT

  • Next message: Mike Kienenberger: "[SOLVED] 1.0rc2 - INSERT not activating Oracle Sequences for primary key generation, NULL instead."

    I'm seeing my primary key set to NULL when I try to commitChanges a new LOG
    object.

    There's no "SELECT LOG_SEQ.NEXT FROM DUAL" (sic) statements being generated.

    I set breakpoints on
    pkFromDatabase(DataNode,DbEntity),generatePkForDBEntity(DataNode,DbEntity),generatePkForDbEntity(DbEntity)
    for OraclePkGenerator,JdbcPkGenerator, and even PkGenerator (although I have
    no idea if that works) and they are never hit.

    Here's my db-entity for LOG:
    ==================================
            <db-entity name="LOG">
                    <db-attribute name="LOG_ID" type="INTEGER" isPrimaryKey="true"
    isMandatory="true" length="8"/>
    [...]
                    <db-key-generator>
                            <db-generator-type>ORACLE</db-generator-type>
                            <db-generator-name>LOG_SEQ</db-generator-name>
                            <db-key-cache-size>20</db-key-cache-size>
                    </db-key-generator>
            </db-entity>
    ==================================

    Oracle sequence LOG_SEQ, successfully used from both Toplink and WebObjects:
    ==================================
    SEQUENCE_NAME MIN_VALUE MAX_VALUE INCREMENT_BY C O
    CACHE_SIZE LAST_NUMBER
    ------------------------------ ---------- ---------- ------------ - -
    ---------- -----------
    LOG_SEQ 1 1.0000E+27 1 N N
     20 187711
    ==================================

    The three SQL statements that should be generated are of the form:
    ===================================
    SELECT LOG_SEQ.NEXT FROM DUAL" (sic)

    INSERT INTO LOG (ADMINISTRATIVE_USER_ID, FIELD_NAME, FOREIGN_RECORD_KEY,
    LOG_ID, MODIFICATION_DATE, NEW_VALUE, OLD_VALUE, TABLE_NAME, USER_ID) VALUES
    (?, ?, ?, ?, ?, ?, ?, ?, ?)

    UPDATE USER_TABLE SET LAST_CONNECT_DATE = x, FAILED_PASSWORD_RESETS = 0,
    FAILED_PASSWORDS = 0 where USER_ID = 56
    ===================================

    Here's the log:

    [...Some successful queries reading data from the database...]

    cayenne DEBUG [Thread-6 09-09 22:07:27] ContextCommit: Creating
    InsertBatchQuery for DbEntity LOG
    cayenne WARN [Thread-6 09-09 22:07:27] QueryLogger: --- will run 2 queries.
    cayenne WARN [Thread-6 09-09 22:07:27] QueryLogger: INSERT INTO LOG
    (ADMINISTRATIVE_USER_ID, FIELD_NAME, FOREIGN_RECORD_KEY, LOG_ID,
    MODIFICATION_DATE, NEW_VALUE, OLD_VALUE, TABLE_NAME, USER_ID) VALUES (?, ?,
    ?, ?, ?, ?, ?, ?, ?)
    cayenne WARN [Thread-6 09-09 22:07:27] QueryLogger: [batch bind: NULL,
    'lastConnectDate', 56, NULL, '2003-09-09 22:07:26.734', 'Tue Sep 09 22:07:26
    EDT 2003', 'Sat Sep 06 21:14:26 EDT 2003', 'User', 56]
    cayenne WARN [Thread-6 09-09 22:07:27] QueryLogger: [batch bind: NULL,
    'failedPasswordResets', 56, NULL, '2003-09-09 22:07:26.734', '0', '0',
    'User', 56]
    cayenne WARN [Thread-6 09-09 22:07:27] QueryLogger: [batch bind: NULL,
    'failedPasswords', 56, NULL, '2003-09-09 22:07:26.734', '0', '0', 'User',
    56]
    cayenne WARN [Thread-6 09-09 22:10:25] QueryLogger: *** error.
    java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into
    ("EBPP"."LOG"."LOG_ID")

            at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
            at
    oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4133)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsBatch(DataNode.java:518)
            at
    org.objectstyle.cayenne.dba.oracle.OracleDataNode.runBatchUpdateAsBatch(OracleDataNode.java:360)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:474)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:287)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:734)
            at com.gvea.struts.ebpp.security.LoginAction.execute(LoginAction.java:397)
    [...]
    cayenne WARN [Thread-6 09-09 22:10:25] QueryLogger: *** nested SQL error.
    java.sql.SQLException: ORA-01400: cannot insert NULL into
    ("EBPP"."LOG"."LOG_ID")

            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
            at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
            at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
            at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
            at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1094)
            at
    oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2132)
            at
    oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2015)
            at
    oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4125)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsBatch(DataNode.java:518)
            at
    org.objectstyle.cayenne.dba.oracle.OracleDataNode.runBatchUpdateAsBatch(OracleDataNode.java:360)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:474)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:287)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:734)
            at com.gvea.struts.ebpp.security.LoginAction.execute(LoginAction.java:397)
    [...]
    cayenne WARN [Thread-6 09-09 22:10:25] QueryLogger: *** error.
    java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into
    ("EBPP"."LOG"."LOG_ID")

            at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
            at
    oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4133)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsBatch(DataNode.java:518)
            at
    org.objectstyle.cayenne.dba.oracle.OracleDataNode.runBatchUpdateAsBatch(OracleDataNode.java:360)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:474)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:287)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:734)
            at com.gvea.struts.ebpp.security.LoginAction.execute(LoginAction.java:397)
    [...]
    cayenne WARN [Thread-6 09-09 22:10:25] QueryLogger: *** nested SQL error.
    java.sql.SQLException: ORA-01400: cannot insert NULL into
    ("EBPP"."LOG"."LOG_ID")

            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
            at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
            at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
            at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
            at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1094)
            at
    oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2132)
            at
    oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2015)
            at
    oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4125)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsBatch(DataNode.java:518)
            at
    org.objectstyle.cayenne.dba.oracle.OracleDataNode.runBatchUpdateAsBatch(OracleDataNode.java:360)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:474)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:287)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:734)
            at com.gvea.struts.ebpp.security.LoginAction.execute(LoginAction.java:397)
    [...]
    cayenne WARN [Thread-6 09-09 22:10:26] QueryLogger: *** transaction rolled
    back.
    cayenne DEBUG [Thread-6 09-09 22:10:26] DefaultOperationObserver: ***
    transaction rolled back

    org.objectstyle.cayenne.CayenneRuntimeException: [v.1.0rc2 September 7 2003]
    Raising from underlyingQueryEngine exception.
            at
    org.objectstyle.cayenne.access.util.ContextCommitObserver.nextGlobalException(ContextCommitObserver.java:188)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:349)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:734)
    [...]
    Caused by: java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into
    ("EBPP"."LOG"."LOG_ID")

            at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
            at
    oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4133)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsBatch(DataNode.java:518)
            at
    org.objectstyle.cayenne.dba.oracle.OracleDataNode.runBatchUpdateAsBatch(OracleDataNode.java:360)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:474)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:287)
            ... 38 more [truncated by logger, not me]



    This archive was generated by hypermail 2.0.0 : Tue Sep 09 2003 - 22:26:05 EDT