[BUG] ORACLE sequence numbers not incrementing....

From: Mike Kienenberger (mkienen..laska.net)
Date: Thu Sep 11 2003 - 15:01:31 EDT

  • Next message: Andrus Adamchik: "Re: [BUG] ORACLE sequence numbers not incrementing...."

    You may disagree with me on this, but I'm going to call the following a bug.

    What Cayenne's XML refers to as "db-key-cache-size" and what the modeler
    refers to as "cached pk size" is really "db-key-increment."

    This value is only used in reference to Oracle sequences, and Oracle
    sequences have a "cache size" property in addition to an "increment by"
    property. From what I can tell reading through the OraclePKGenerator.java
    file, the "db-key-cache-size" value is only used for the "increment by"
    value, and not for the "cache size". At best this is highly confusing and
    misleading. At worse, I'll call it a bug :)

    Along with that, the default value is "20" which is the default value for an
    Oracle cache_size, while the default value for an Oracle sequence
    increment_by is 1, which only reinforces the misconception (as well as makes
    it incompatible by default with existing database frameworks' default
    increment_by [EOF/Toplink]).

    I think it's important to correct this misleading nomenclature before it
    becomes a conflicting grandfathered-in Cayenne "standard."

    Maybe we can rename it to "db-key-sequence-cache-size" and
    "db-key-sequence-increment-by" and depreciate "db-key-cache-size." That's
    not ideal, but it might be too late to change the meaning of
    "db-key-cache-size" to be what it means in other contexts.

    Comments?

    -Mike

    Mike Kienenberger <mkienen..laska.net> wrote:
    > I'm seeing the same set of oracle numbers reused over and over and no
    > sequence increment. Any ideas what might be causing the problem? Here's
    the
    > details.
    >
    >
    > I'm running my struts application inside Eclipse using the SYSDEO Tomcat
    > plugin and Tomcat 4.1.27.
    > I'm connecting to Oracle 9i.
    >
    > My oracle sequence is as follows.
    >
    > SEQUENCE_NAME MIN_VALUE MAX_VALUE INCREMENT_BY C O
    > CACHE_SIZE
    >
    > ------------------------------ ---------- ---------- ------------ - -
    > ----------
    >
    > LAST_NUMBER
    >
    > -----------
    >
    > LOG_SEQ 1 1.0000E+27 1 N N
      
    > 20
    >
    > 187731
    >
    >
    > My DbEntity definition is:
    >
    >
    > <db-entity name="LOG">
    >
    > <db-attribute name="ADMINISTRATIVE_USER_ID" type="INTEGER" length="8"/>
    >
    > <db-attribute name="FIELD_NAME" type="VARCHAR" isMandatory="true"
    > length="32"/>
    >
    > <db-attribute name="FOREIGN_RECORD_KEY" type="INTEGER" length="8"/>
    >
    > <db-attribute name="LOG_ID" type="INTEGER" isPrimaryKey="true"
    > isMandatory="true" length="8"/>
    >
    > <db-attribute name="MODIFICATION_DATE" type="DATE" isMandatory="true"/>
    >
    > <db-attribute name="NEW_VALUE" type="VARCHAR" length="255"/>
    >
    > <db-attribute name="OLD_VALUE" type="VARCHAR" length="255"/>
    >
    > <db-attribute name="TABLE_NAME" type="VARCHAR" isMandatory="true"
    > length="32"/>
    >
    > <db-attribute name="USER_ID" type="INTEGER" 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>
    >
    >
    >
    > Starting with a new instance of my application, I start generating
    sequence
    > numbers between 187711 (20 below the LOG_SEQ.LAST_NUMBER value, 20 being
    my
    > cache size) and 187716. However, the This does not increase the
    database's
    > LOG_SEQ.LAST_NUMBER. It remains constant at 187731, the value before the
    > application started.
    >
    > This is suspiciously (and the cache size is 20 both in the oracle table

    > and in my model definition).
    >
    > Note that
    >
    > cayenne WARN [Thread-6 09-10 17:44:43] 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-10 17:44:43] QueryLogger: [batch bind: NULL,
    > 'lastConnectDate', 56, 187716, '2003-09-10 17:44:43.14', 'Wed Sep 10
    > 17:44:43 EDT 2003', 'Wed Sep 10 00:00:00 EDT 2003', 'User', 56]
    >
    > cayenne WARN [Thread-6 09-10 17:44:43] QueryLogger: [batch bind: NULL,
    > 'failedPasswordResets', 56, 187717, '2003-09-10 17:44:43.14', '0', '0',
    > 'User', 56]
    >
    > cayenne WARN [Thread-6 09-10 17:44:43] QueryLogger: [batch bind: NULL,
    > 'failedPasswords', 56, 187718, '2003-09-10 17:44:43.14', '0', '0', 'User',

    > 56]
    >
    >
    > [...]
    >
    > cayenne WARN [Thread-3 09-10 17:45:47] QueryLogger: [batch bind: NULL,
    > 'lastConnectDate', 56, 187720, '2003-09-10 17:45:47.437', 'Wed Sep 10
    > 17:45:47 EDT 2003', 'Wed Sep 10 00:00:00 EDT 2003', 'User', 56]
    >
    > cayenne WARN [Thread-3 09-10 17:45:47] QueryLogger: [batch bind: NULL,
    > 'failedPasswords', 56, 187721, '2003-09-10 17:45:47.437', '0', '1',
    'User',
    > 56]
    >
    > cayenne WARN [Thread-3 09-10 17:45:47] QueryLogger: [batch bind: NULL,
    > 'failedPasswordResets', 56, 187722, '2003-09-10 17:45:47.437', '0', '0',
    > 'User', 56]
    >
    >
    > [...]
    >
    > cayenne WARN [Thread-16 09-10 17:47:17] QueryLogger: [batch bind: NULL,
    > 'lastConnectDate', 56, 187732, '2003-09-10 17:47:16.531', 'Wed Sep 10
    > 17:47:16 EDT 2003', 'Wed Sep 10 00:00:00 EDT 2003', 'User', 56]
    >
    > cayenne WARN [Thread-16 09-10 17:47:17] QueryLogger: [batch bind: NULL,
    > 'failedPasswordResets', 56, 187714, '2003-09-10 17:47:16.531', '0', '0',
    > 'User', 56]
    >
    > cayenne WARN [Thread-16 09-10 17:47:17] QueryLogger: [batch bind: NULL,
    > 'failedPasswords', 56, 187715, '2003-09-10 17:47:16.531', '0', '0',
    'User',
    > 56]
    >
    > Note that we've now passed 187731 by 1, then started over at 187714.
    >
    > at which point we throw:
    >
    > Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint
    > (EBPP.SYS_C001743) violated
    >
    >
    > which is LOG_ID in my LOG table.
    >
    >
    > If anyone has any ideas before I start debugging this line-by-line
    tomorrow
    > morning, I'd love to hear them :) My experience with "raw access" to
    > sequences is minimal.
    >
    > -Mike
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Sep 11 2003 - 14:58:10 EDT