Re: Null property exceptions
Re: Null property exceptions
- Subject: Re: Null property exceptions
- From: Jeff Schmitz <email@hidden>
- Date: Tue, 3 Jun 2008 06:40:47 -0700
HI Alexander,
So, to "propagate primary key" between two entities that have a
"one to one" relationship, how would need to specify that? As noted
in my recent message, I set "propagate" on the relationship in the
relationship editor, but the foreign key remains in Entry with no
seeming way to delete it.
thanks,
Jeff
On Jun 3, 2008, at 4:18 AM, Alexander Spohr wrote:
Jeff,
you don’t want to propagate anything here.
entryScoreID is not a primary-key but a foreign-key, so you can not
propagate it.
Owns Destination is wrong as well. You designed your relationships
backwards (read: wrong).
And you’ll need to set all other relationships as well before you
saveChanges, as none of the fks allow NULL.
atze
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
---
Alexander Spohr
Freeport & Soliversum
Fax: +49 40 303 757 99
Web: http://www.freeport.de/
Box: http://dropbox.letsfile.com/02145299-4347-4671-aab9-1d3004eac51d
---
_______________________________________________
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