Re: deep down NPE in EOF
Re: deep down NPE in EOF
- Subject: Re: deep down NPE in EOF
- From: Ken Anderson <email@hidden>
- Date: Mon, 5 Nov 2007 09:04:26 -0500
Since you state that all StoredName objects have MyAppPerson data,
why not just fetch MyAppPerson initially and have a to-one
relationship back to StoredName?
On Nov 4, 2007, at 7:32 PM, Chuck Hill wrote:
On Nov 4, 2007, at 8:09 AM, Zak Burke wrote:
I'm getting a strange NPE from deep down in EOF that I can't
figure out. I think it might be related to some slightly funky
modeling I'm doing,
It is. :-)
but my EOs work fine in other places so I'm not sure why they're
broken here.
Here's the funkiness: I have two models -- NameStore and MyApp.
NameStore contains a single EO, StoredName. MyApp has an EO
MyAppPerson that extends StoredName, but the restricting qualifier
is just "id > 0", that is, all StoredName EOs are MyAppPerson EOs.
Basically, we have lots of (non-WO) apps that use the StoredName
table and have their own tables joined to it. I modeled it in WO
this way to keep the NameStore EO pristine -- all it does is hand
out names -- while allowing other apps to tack things onto a local
EO that extends StoredName.
What I want to do is retrieve a StoredName and then bless it into
existence by re-fetching it as a MyAppPerson
Can't. When you fetch it as a StoredName, EOF associates the
GlobalID with that entity. When you re-fetch it as MyAppPerson,
EOF will still treat it as a StoredName.
You are going to have to fetch it as a MyAppPerson the first time.
Chuck
so I can access all its related objects. Because the StoredName
and the MyAppPerson share the same primary key value, I'm just
passing storedName.id() to a MyAppPerson method that retrieves
items by their PKs.
try {
return (MyAppPerson) EOUtilities.objectMatchingKeyAndValue(ec,
MyAppPerson.ENTITY_NAME, MyAppPerson.ID_KEY, id);
} catch (EOObjectNotAvailableException e) {
throw new RuntimeException("An MyAppPerson identified by " + id +
" could not be found.");
} catch (EOUtilities.MoreThanOneException e) {
throw new RuntimeException("More than one MyAppPerson identified
by " + id + " was found.");
}
The fetch works fine; I get an object back. But EOF explodes when
I true access it, even just item.toString() to print it to a log
(stacktrace below). It appears to be exploding after traversing an
optional to-many join. I can use MyAppPerson items elsewhere so I
don't think I have modeling errors, but, well, I'm totally
stumped. Any ideas?
TIA,
zak.
[2007-11-04 10:18:08 EST] <WorkerThread0>
java.lang.NullPointerException
at
com.webobjects.eoaccess.EODatabaseContext.arrayFaultWithSourceGlobalI
D(EODatabaseContext.java:3664)
at
com.webobjects.eoaccess.EODatabaseContext._fireDeferredFaultWithSourc
eObject(EODatabaseContext.java:2551)
at
com.webobjects.eoaccess.EOAccessDeferredFaultHandler.createFaultForDe
ferredFault(EOAccessDeferredFaultHandler.java:45)
at com.webobjects.eocontrol.EOCustomObject.willReadRelationship
(EOCustomObject.java:1302)
at com.webobjects.eocontrol._EOMutableKnownKeyDictionary
$Initializer$_LazyGenericRecordBinding.valueInObject
(_EOMutableKnownKeyDictionary.java:560)
at com.webobjects.eocontrol.EOCustomObject.storedValueForKey
(EOCustomObject.java:1736)
at edu.dartmouth.dltg.authorization.eos._AuthzPerson.roles
(_AuthzPerson.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation.NSKeyValueCoding$ValueAccessor
$1.methodValue(NSKeyValueCoding.java:684)
at com.webobjects.foundation.NSKeyValueCoding
$_MethodBinding.valueInObject(NSKeyValueCoding.java:1160)
at com.webobjects.eocontrol.EOCustomObject.valueForKey
(EOCustomObject.java:1559)
at com.webobjects.eocontrol.EOCustomObject.eoDescription
(EOCustomObject.java:793)
at com.webobjects.eocontrol.EOCustomObject.toString
(EOCustomObject.java:239)
at java.lang.String.valueOf(String.java:2615)
at java.lang.StringBuffer.append(StringBuffer.java:220)
at edu.dartmouth.dltg.authorization.pages.RoleEditPeople.doSaveDnd
(RoleEditPeople.java:138)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
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:
40anderhome.com
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