Re: error in entity creation

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Oct 16 2003 - 11:44:46 EDT

  • Next message: jini us: "Date of Birth Artist"

    Hi Johannes,

    Looks like automatic primary key support is not configured for the
    table "kaufposten". You could create it using the modeler, but to avoid
    overwriting existing entries, I recommend running this SQL manually
    instead:

    INSERT INTO AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES('kaufposten',
    1)

    Hope this helps.
    Andrus

    On Thursday, October 16, 2003, at 05:13 AM, johannes schmidt wrote:

    > Whenever I try to create a certain new cayenne object (called
    > Kaufposten) I
    > get a strange exception. The rest of my application using cayenne is
    > running
    > perfectly. I send the datamap together with this email.
    > Here's my code:
    >
    > this.db=(Kaufposten)ctxt.createAndRegisterNewObject("Kaufposten");
    > this.db.setBezahlt(new Byte((byte)0));
    > this.db.setAnzahl(new
    > Integer(Integer.parseInt(this.tfAnzahl.getText())));
    > this.db.setDatum(new
    > java.sql.Date(akj.helpers.Verify.dateCheck(this.tfDatum.getText()).getT
    > ime()
    > ));
    > // This person was created before and works whenever I set it in other
    > relations!
    > this.db.setPerson(this.dbp.getPerson());
    > // This was created before and works!
    > Kostenstelle k=(Kostenstelle)this.dbcKostenstelle.getSelectedItem();
    > this.db.setKostenstelle(k);
    > try{
    > ctxt.commitChanges();
    > }
    > --->>>>
    > exception catched at that point:
    > org.objectstyle.cayenne.CayenneRuntimeException: [v.1.0 September 20
    > 2003]
    > org.objectstyle.cayenne.CayenneException: [v.1.0 September 20 2003]
    > Error
    > generating PK: No rows for 'kaufposten'
    >
    > MySql Code:
    > CREATE TABLE `kaufposten` (
    > `P_ID` int(16) NOT NULL default '0',
    > `Nummer` int(16) NOT NULL default '0',
    > `Datum` date NOT NULL default '0000-00-00',
    > `bezahlt` tinyint(1) default '0',
    > `anzahl` int(16) default '0',
    > PRIMARY KEY (`P_ID`,`Nummer`,`Datum`),
    > KEY `Nummer` (`Nummer`),
    > FOREIGN KEY (`P_ID`) REFERENCES `person` (`P_ID`) ON DELETE CASCADE,
    > FOREIGN KEY (`Nummer`) REFERENCES `kostenstelle` (`Nummer`) ON DELETE
    > CASCADE
    > ) TYPE=InnoDB;
    >
    > Anybody knows something about this?
    >
    > thanks in advance,
    > johannes
    > <Adress_DB.map.xml>



    This archive was generated by hypermail 2.0.0 : Thu Oct 16 2003 - 11:44:46 EDT