error in entity creation

From: johannes schmidt (e002753..tudent.tuwien.ac.at)
Date: Thu Oct 16 2003 - 05:13:42 EDT

  • Next message: Andrus Adamchik: "Re: error in entity creation"

    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()).getTime()
    ));
    // 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





    This archive was generated by hypermail 2.0.0 : Thu Oct 16 2003 - 05:13:48 EDT