• 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
Re: Null property exceptions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Null property exceptions


  • Subject: Re: Null property exceptions
  • From: Jeff Schmitz <email@hidden>
  • Date: Tue, 3 Jun 2008 06:25:40 -0700

Yes, I had wondered about that myself. The foreign key is a product of the GUI as when you create a new relationship, there is no way (that I could find) to specify initially that you want it to propagate the primary key, so its created initially whenever you create a new relationship. Then, when you specify later to "propagate primary key" from the relationship editor, the foreign key remains, so I thought perhaps is kept there, but entryScoreID is always equated with its own ID in the implementation. Should/could perhaps the GUI auto-delete the foreign key when "propagate primary key" is selected? Would at least help DB neophytes like myself.

Also, I really don't care to get back to Entry from EntryScore, and anyway, if an entry's key is being propagated to its related entryScore, shouldn't you be able to get back to the entry from the entryScore by just using entryScore's ID (since it's the associated entry's ID too)?

Anyway, I'll try removing the foreign key and see what happens. I thought I had actually tried it before and got some other error, but I'll give it another shot.
And thanks for the GREAT discussion, I've already gotten answers to a lot of lingering questions I had in my head.



Jeff

On Jun 3, 2008, at 12:01 AM, Johann Werner wrote:

Why do you have the attribute "entryScoreID" in the Entry entity? If you make a to-one relationship Entry->EntryScore and propagate the PK you only need an FK attribute in EntryScore that gets set to the PK of Entry by EOF.
In your exception it is complaining about the entryScoreID from Entry _not_ from EntryScore.


jw


Am 03.06.2008 um 06:58 schrieb Jeff Schmitz:

No, I don't think I have an foreign keys exposed. If they were, they'd have the little diamond by them, right?

<entryScore.jpg>

On Jun 2, 2008, at 9:46 PM, Chuck Hill wrote:


On Jun 2, 2008, at 9:42 PM, Jeff Schmitz wrote:

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?

Well, uh, how do you have it set? Do you have any foreign key exposed as a class property? If so, don't! You can make the PK a class property (not saying this a good idea, just that it won't cause errors), but exposing an FK will cause this sort of error.



Chuck

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ 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

--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ 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


_______________________________________________ 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
References: 
 >Null property exceptions (From: Jeff Schmitz <email@hidden>)
 >Re: Null property exceptions (From: Johann Werner <email@hidden>)
 >Re: Null property exceptions (From: Jeff Schmitz <email@hidden>)
 >Re: Null property exceptions (From: Chuck Hill <email@hidden>)
 >Re: Null property exceptions (From: Jeff Schmitz <email@hidden>)
 >Re: Null property exceptions (From: Johann Werner <email@hidden>)

  • Prev by Date: Re: Null property exceptions
  • Next by Date: Re: Null property exceptions
  • Previous by thread: Re: Null property exceptions
  • Next by thread: Re: Null property exceptions
  • Index(es):
    • Date
    • Thread