RE: MySql auto generated PK

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Wed Jun 21 2006 - 11:38:33 EDT

  • Next message: Borut Bolčin: "Re: MySql auto generated PK"

    I don't believe InnoDB has anything to do with it. When the table was
    created, the primary key (oid) was declared to be an AUTO_INCREMENT
    field.

    /dev/mrg

    -----Original Message-----
    From: Borut Bolcina [mailto:bo..ajdi.si]
    Sent: Wednesday, June 21, 2006 11:19 AM
    To: cayenne-use..ncubator.apache.org
    Subject: Re: MySql auto generated PK

    Log file at table creation time says:

    CREATE TABLE foo.bar (cir FLOAT NULL, content_type VARCHAR(100) NULL,
    custom_last_modified DATE NULL, header_etag VARCHAR(100) NULL,
    header_last_modified VARCHAR(100) NULL, *oid INT NOT NULL
    AUTO_INCREMENT*, title VARCHAR(500) NULL, type VARCHAR(30) NOT NULL, url

    VARCHAR(1000) NOT NULL, verified BIT NOT NULL, PRIMARY KEY (oid))
    ENGINE=InnoDB

    Does InnoDB has something to do with the problem?

    -Borut

    Gentry, Michael (Contractor) pravi:
    > http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
    >
    > Check to see if your DB is using auto-increment ...
    >
    >
    > -----Original Message-----
    > From: Gentry, Michael (Contractor)
    [mailto:michael_gentr..anniemae.com]
    >
    > Sent: Wednesday, June 21, 2006 9:13 AM
    > To: cayenne-use..ncubator.apache.org
    > Subject: RE: MySql auto generated PK
    >
    >
    > I didn't keep up with the MySQL stuff too much, but I believe support
    > was added (sometime in 1.2) for auto-increment columns. The
    > isGenerated="true" is what controls it, I believe. Assuming my memory
    > is working, that attribute tells Cayenne to not use the
    AUTO_PK_SUPPORT
    > table and instead rely on MySQL to auto-increment the value and return
    > it to Cayenne.
    >
    > /dev/mrg
    >
    >
    > -----Original Message-----
    > From: Borut Bolcina [mailto:bo..ajdi.si]
    > Sent: Wednesday, June 21, 2006 2:53 AM
    > To: cayenne-use..ncubator.apache.org
    > Subject: MySql auto generated PK
    >
    >
    > Is something broken or am I missing something in my setup, but when
    > inserting, Cayenne is generating PK instead of using AUTO_PK_SUPPORT.
    >
    > I use Cayenne 1.2RC1, mysql-connector-java-3.1.13
    > This is mapping:
    > <db-attribute name="oid" type="INTEGER" isPrimaryKey="true"
    > isGenerated="true" isMandatory="true"/>
    >
    > and this is how I generate the tables
    > MySQLAdapter mysqlDbAdapter = new MySQLAdapter();
    > mysqlDbAdapter.setSupportsFkConstraints(true);
    > mysqlDbAdapter.setSupportsGeneratedKeys(true);
    > generator = new DbGenerator(mysqlDbAdapter, dataMap);
    > generator.setShouldCreatePKSupport(true);
    > generator.setShouldCreateFKConstraints(true);
    > generator.setShouldDropTables(false);
    > generator.runGenerator(dataSource);
    >
    > AUTO_PK_SUPPORT table gets generated and correctly populated with
    table
    > names and initial value 200.
    >
    > When inserting records, Cayenne inserts records with PK 1,2,3,...
    > ignoring AUTO_PK_SUPPORT. No SELECT FROM AUTO_PK_SUPPORT happens in
    log
    > files.
    >
    > What did I miss. I think this worked months ago when exercising
    Cayenne
    > with some simple examples.
    >
    > Cheers,
    > Borut
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Jun 21 2006 - 11:39:02 EDT