thanks!
You're exactly right, that relationship is an owns destination relationship. I changed the code to set the properties on the existing entryScore instead of creating a new one:

   EOQualifier poolQual = Pool.NAME.eq(name);
   pool = Pool.fetchRequiredPool(ec, poolQual);
entry = Entry.createEntry(ec, "DEFAULT", "pw", true, false, new Integer(0), "", false, false, false, new Integer(0), pool, user);
   entry.entryScore().setNumSecs(0);
   entry.entryScore().setNumThirds(0);
   entry.entryScore().setNumWins(0);
   entry.entryScore().setPlace(0);
   entry.entryScore().setPoints(0);
   entry.entryScore().setPotential(0);
   ec.saveChanges();

but now I'm getting a different validation error. There's probably still something I don't have setup right for using the "propagates primary key" and "owns destination" options for this relationship, but I'm not sure what it is. It's interesting that the below INSERT passes in a NULL value for the entryScoreID. If it automatically creates its own entryScore object, shouldn't it be sending in the ID of that object instead of NULL?


com.webobjects.eoaccess.EOGeneralAdaptorException: EvaluateExpression failed: <com.webobjects.jdbcadaptor.FrontbasePlugIn $FrontbaseExpression: "INSERT INTO "t_entry"("c_still_alive_first", "c_games", "c_still_alive_third", "spare_int", "userID", "id", "c_name", "c_picks_confirmed", "spare_bool", "c_last_save", "c_groups", "entryScoreID", "poolID", "entryAdminID", "c_still_alive_second", "spare_str", "c_password", "c_tie_breaker") VALUES ('false', 15, 'false', 0, 1000001, 1000001, 'DEFAULT', 'true', 'false', TIMESTAMP '2008-06-02 21:32:13.802', 4, NULL, 1000001, NULL, 'false', '', 'pw', 0)" withBindings: >: Next exception:SQL State:23 subclass = 00 -- error code: 357 -- msg: Exception condition 357. Integrity constraint violation (CHECK, t_entry.NOT_NULL_t_entry__entryScoreID(\"entryScoreID\" IS NOT NULL)).

Thanks,
Jeff


On Jun 2, 2008, at 12:49 AM, Johann Werner wrote:

Hi Jeff,

what is your entryScore relationship like? Do you have "owns destination" checked? If yes then by creating an Entry object EOF does create an EntryScore object for you automatically. So when you save changes that object is still in the editing context but no attributes have been set and thus throwing NullPropertyExceptions for every attribute that does not allow Null.

jw


Am 02.06.2008 um 04:35 schrieb Jeff Schmitz:

Hello,
I can't get past NullPropertyException's when I try to save changes to my editing context. I have an object, pool, that I add an entry to with the Entry.createEntry operation. Then, in turn, I add an EntryScore obejct to the entry object. Note that the entryScore relationship in Entry (the one causing the problems) is set to "propagate primary key". I have tried making it both mandatory and optional with the same results. Any ideas what may be causing this?

Here's the basic code:

  EOQualifier poolQual = Pool.NAME.eq(name);
  pool = Pool.fetchRequiredPool(ec, poolQual);
entry = Entry.createEntry(ec, "DEFAULT", "pw", true, false, new Integer(0), "", false, false, false, new Integer(0), pool, user);
  EntryScore es = EntryScore.createEntryScore(ec, 0, 0, 0, 0, 0, 0);
  entry.setEntryScore(es);
  ec.saveChanges();

exception (on the SaveChanges line):

Jun 01 21:19:54 netBrackets[64375] (ERXNSLogLog4jBridge.java:41) WARN NSLog - <com.webobjects.appserver._private.WOComponentRequestHandler>: Exception occurred while handling request: <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: numSecs; type: NullPropertyException; additionalExceptions: ( <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: numThirds; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: numWins; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: place; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: points; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: potential; type: NullPropertyException; additionalExceptions: ( )> )> [2008-6-2 3:19:54 CDT] <WorkerThread0> <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: numSecs; type: NullPropertyException; additionalExceptions: ( <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: numThirds; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: numWins; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: place; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: points; type: NullPropertyException; additionalExceptions: ( )>, <er.extensions.ERXValidationException object: <com.netbracketsfw.model.EntryScore pk:"null">; propertyKey: potential; type: NullPropertyException; additionalExceptions: ( )> )> at com.webobjects.eoaccess.EOAttribute.validateValue(EOAttribute.java: 2541) at com .webobjects .eoaccess .EOEntityClassDescription .validateValueForKey(EOEntityClassDescription.java:452) at er .extensions .ERXEntityClassDescription .validateValueForKey(ERXEntityClassDescription.java:796) at com .webobjects .eocontrol.EOCustomObject.validateValueForKey(EOCustomObject.java: 1311) at er .extensions .ERXGenericRecord.validateValueForKey(ERXGenericRecord.java:1063) at com .webobjects .eocontrol.EOCustomObject.validateForSave(EOCustomObject.java:1381) at er .extensions.ERXGenericRecord.validateForSave(ERXGenericRecord.java: 1109) at com .webobjects .eocontrol.EOCustomObject.validateForInsert(EOCustomObject.java:1433) at er .extensions .ERXGenericRecord.validateForInsert(ERXGenericRecord.java:1132) at com .webobjects .eocontrol.EOEditingContext.validateTable(EOEditingContext.java:2265) at com .webobjects .eocontrol .EOEditingContext.validateChangesForSave(EOEditingContext.java:2991) at com .webobjects .eocontrol .EOEditingContext._prepareForPushChanges(EOEditingContext.java:3233) at com .webobjects .eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3163)
        at er.extensions.ERXEC._saveChanges(ERXEC.java:937)
        at er.extensions.ERXEC.saveChanges(ERXEC.java:860)

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/werner%40isd.uni-stuttgart.de

This email sent to [EMAIL PROTECTED]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to