cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Senecal <>
Subject Re: Generated primary keys are being truncated
Date Fri, 20 Jul 2012 00:19:17 GMT
We're using Oracle and sequences, not an AUTO_PK table to generate the keys. I've added logging
into the custom code that pulls sequences, and the values are right at that point. But when
I look at the code that calls that, I find right after the call:
        if (pk.getType() == Types.BIGINT) {
            return Long.valueOf(value);
        else {
            // leaving it up to the user to ensure that PK does not exceed max int...
            return Integer.valueOf((int) value);

How do I specify a primary key type to be BIGINT? Would anything break if I changed my copy
of this code to always return a Long instead of an Integer?


On Jul 19, 2012, at 5:15 PM, Aristedes Maniatis wrote:

> Look at the columns widths of the AUTO_PK table?
> Ari
> On 20/07/12 10:07am, Joseph Senecal wrote:
>> We are using Cayenne 3.1 M3 in production. We have just discovered that the primary
keys being generated are being truncated to fit an int.
>> The sequence returns numbers like 5224748590. I've confirmed this by logging the
return value of LongPkRange.getNextPrimaryKey.
>> But the inserts are using PKs like 929781294. 5224748590 - 2^32 = 929781294. Something
is stripping off the high order bits of the primary keys.
>> I've checked my model, there the primary key is Defined as Number(15) in the database,
but it isn't defined as an attribute at all, so I can't specify the Java class to use for
>> Anyone have any suggestions?
> -- 
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

View raw message