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
|