• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Primary Key not present on insert
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Primary Key not present on insert


  • Subject: Primary Key not present on insert
  • From: Tobias Crawley <email@hidden>
  • Date: Tue, 1 Jan 2008 14:36:02 -0500

I'm having an odd issue that maybe someone on the list can shed some light on. I recently started a new project, and decided to try Frontbase instead of my usual MySQL. I am having an issue where EOF is not supplying the pk (id) on insert for one of my EO's. The EO in question (Diagnosis) is a join table between a Card and a DiagnosisCode, with some additional information. The relationship between Card and DiagnosisCode is not flattened.

I create a Card in an EC via Card.createCard() (from the stock Velocity template), then create a Diagnosis in the same EC via Diagnosis.createDiagnosis(), join the two via card.addToDiagnosesRelationship( diagnosis ). Then I save the EC, and get the following log output (the underlined $$$ prefixed output is from a primaryKeyInTransaction() call before the save to make sure it is properly generating the pk, and the bold output is the insert/constraint failure):

Jan 01 14:08:22 YellowCard[2323] (_Card.java:80) DEBUG org.carepartners.yellowcard._Card  - updating patientName from null to test
Jan 01 14:08:22 YellowCard[2323] (_Card.java:91) DEBUG org.carepartners.yellowcard._Card  - updating patientNumber from null to test
Jan 01 14:08:22 YellowCard[2323] (_Card.java:47) DEBUG org.carepartners.yellowcard._Card  - updating careType from null to Hospice
Jan 01 14:08:22 YellowCard[2323] (_Diagnosis.java:49) DEBUG org.carepartners.yellowcard._Diagnosis  - updating card from null to <org.carepartners.yellowcard.Card pk:"null">
Jan 01 14:08:22 YellowCard[2323] (_Diagnosis.java:67) DEBUG org.carepartners.yellowcard._Diagnosis  - updating diagnosisCode from null to <org.carepartners.yellowcard.DiagnosisCode pk:"1000001">
Jan 01 14:08:22 YellowCard[2323] (_Card.java:234) DEBUG org.carepartners.yellowcard._Card  - adding <org.carepartners.yellowcard.Diagnosis pk:"null"> to diagnoses relationship
Jan 01 14:08:22 YellowCard[2323] (_Diagnosis.java:38) DEBUG org.carepartners.yellowcard._Diagnosis  - updating altDescription from null to asf
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  === Begin Internal Transaction
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  evaluateExpression: <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "VALUES (SELECT UNIQUE FROM "Diagnosis")">
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  - fetch canceled
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  - 1 row(s) processed
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  === Commit Internal Transaction
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:38) INFO  NSLog  - $$$$ diagnosis.primaryKeyInTransaction(): 1000001
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  === Begin Internal Transaction
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  evaluateExpression: <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "VALUES (SELECT UNIQUE FROM "Card")">
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  - fetch canceled
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  - 1 row(s) processed
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  === Commit Internal Transaction
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  === Begin Internal Transaction
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  evaluateExpression: <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "INSERT INTO "Card"("referringMDID", "roomNumber", "patientNumber", "userID", "patientName", "dateSeen", "careType", "processed", "cPTCodeID", "locationID", "patientDateOfBirth", "id") VALUES (1000004, NULL, 'test', 1000001, 'test', TIMESTAMP '2008-01-01 14:07:14.000', 'Hospice', 0, 1000003, 1000002, TIMESTAMP '1928-01-01 14:07:14.000', 1000001)">
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  evaluateExpression: <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "INSERT INTO "Diagnosis"("cardID", "diagnosisCodeID", "altDescription") VALUES (1000001, 1000001, 'asf')">
Jan 01 14:08:22 YellowCard[2323] (ERXDatabaseContextDelegate.java:106) INFO  er.transaction.adaptor.Exceptions  - Database Exception occured: com.webobjects.eoaccess.EOGeneralAdaptorException: EvaluateExpression failed: <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "INSERT INTO "Diagnosis"("cardID", "diagnosisCodeID", "altDescription") VALUES (1000001, 1000001, 'asf')">:
    Next exception:SQL State:23       subclass = 00 -- error code: 357 -- msg: Exception condition 357. Integrity constraint violation (CHECK, Diagnosis.NOT_NULL_Diagnosis__id(\"id\" IS NOT NULL)).
    Next exception:SQL State:23       subclass = 00 -- error code: 359 -- msg: Exception condition 359. Integrity constraint violation (NULL in PRIMARY KEY, Diagnosis.PRIMARY_KEY_Diagnosis_id(id=NULL)).
    Next exception:SQL State:40       subclass = 00 -- error code: 363 -- msg: Exception condition 363. Transaction rollback.
Jan 01 14:08:22 YellowCard[2323] (ERXNSLogLog4jBridge.java:44) DEBUG NSLog  -  === Rollback Internal Transaction

My versions: Java 1.5 WO 5.3/Tiger Frontbase 4.2.8 w/the latest FrontBasePlugIn from Wonder (built from CVS today)

My model for Diagnosis:

{
    attributes = (
        {
            allowsNull = Y; 
            columnName = altDescription; 
            name = altDescription; 
            prototypeName = varchar255; 
        }, 
        {columnName = cardID; name = cardID; prototypeName = id; }, 
        {columnName = diagnosisCodeID; name = diagnosisCodeID; prototypeName = id; }, 
        {name = id; prototypeName = id; }
    ); 
    attributesUsedForLocking = (id); 
    className = "org.carepartners.yellowcard.Diagnosis"; 
    classProperties = (altDescription, card, diagnosisCode); 
    externalName = Diagnosis; 
    fetchSpecificationDictionary = {}; 
    name = Diagnosis; 
    primaryKeyAttributes = (id); 
    relationships = (
        {
            destination = Card; 
            isMandatory = Y; 
            isToMany = N; 
            joinSemantic = EOInnerJoin; 
            joins = ({destinationAttribute = id; sourceAttribute = cardID; }); 
            name = card; 
        }, 
        {
            destination = DiagnosisCode; 
            isMandatory = Y; 
            isToMany = N; 
            joinSemantic = EOInnerJoin; 
            joins = ({destinationAttribute = id; sourceAttribute = diagnosisCodeID; }); 
            name = diagnosisCode; 
        }
    ); 
}

I do not know how EOF works internally to assign the PK, so I'm not sure where to look. Any insight would be appreciated.

Thanks,
Tobias
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Primary Key not present on insert
      • From: Art Isbell <email@hidden>
    • Re: Primary Key not present on insert
      • From: ute Hoffmann <email@hidden>
  • Next by Date: eclipse not running new project???
  • Next by thread: Re: Primary Key not present on insert
  • Index(es):
    • Date
    • Thread