I'm sure I'm close to understanding this... thanks for bearing with me.
On 03/11/2008, at 1:19 PM, Ken Anderson wrote:
On Nov 1, 2008, at 10:51 PM, Paul Hoadley wrote:
I've implemented it using HI, and it seems to be working. I'm not
convinced I have it quite right, though. There's another EO in the
utility-framework's model, UserPreference. UserPreference has a to-
one relationship with Person to denote the owner of the
preference. In the particular app, though, I'm now using
AMPersons, and hence the amperson table in the database---but
UserPreference.person relationship obviously looks for a Person in
the 'person' table, and there aren't any. To overcome this, I have
sub-classed UserPreference to create AMUserPreference, with the
only change being that the person relationship points to AMPerson.
This seems inelegant to me---am I doing it right? (Or is this a
candidate for the kind of dynamic model change you refer to above?)
This is why it would be better for Person to be abstract, and have
different subentities for each application. That way,
UserPreference could have a relationship to the abstract Person
entity, which would automatically search all the subentities for the
correct one for that particular primary key.
I've made Person abstract in the model. I've deleted the redundant EO
(AMUserPreference), and UserPreference (which is in the same framework
as Person) points to the abstract Person entity. I no longer generate
a 'person' table, as I won't be instantiating Person. Now, where the
app would create a UserPreference, I get this on saving:
[2008-11-3 15:33:36 CST] <WorkerThread0>
<com.webobjects.appserver._private.WOComponentRequestHandler>:
Exception occurred while handling request:
java.lang.NullPointerException
Application.handleException: Handling an Exception:
java.lang.NullPointerException
at
com
.webobjects
.eoaccess
.EODatabaseContext
._verifyNoChangesToReadonlyEntity(EODatabaseContext.java:4696)
at
com
.webobjects
.eoaccess.EODatabaseContext.performChanges(EODatabaseContext.java:6183)
at
com
.webobjects
.eocontrol
.EOObjectStoreCoordinator
.saveChangesInEditingContext(EOObjectStoreCoordinator.java:376)
at
com
.webobjects
.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3176)
at
net
.logicsquad
.am
.components
.pages.UserPreferencesPage.saveButtonAction(UserPreferencesPage.java:23)
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:636)
at com.webobjects.foundation.NSKeyValueCoding
$_MethodBinding.valueInObject(NSKeyValueCoding.java:1134)
at com.webobjects.foundation.NSKeyValueCoding
$DefaultImplementation.valueForKey(NSKeyValueCoding.java:1293)
at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:
1686)
at com.webobjects.foundation.NSKeyValueCoding
$Utility.valueForKey(NSKeyValueCoding.java:447)
at com.webobjects.foundation.NSKeyValueCodingAdditions
$DefaultImplementation.valueForKeyPath(NSKeyValueCodingAdditions.java:
212)
at net.logicsquad.am.AMComponent.valueForKeyPath(AMComponent.java:153)
at
com
.webobjects
.appserver
._private
.WOKeyValueAssociation.valueInComponent(WOKeyValueAssociation.java:50)
at
com
.webobjects
.appserver._private.WOSubmitButton.invokeAction(WOSubmitButton.java:81)
at
com
.webobjects
.appserver
._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105)
at
com
.webobjects
.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:115)
at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:
141)
at
com
.webobjects
.appserver
._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105)
at
com
.webobjects
.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:115)
at
com
.webobjects
.appserver
._private.WOComponentContent.invokeAction(WOComponentContent.java:38)
at
com
.webobjects
.appserver
._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105)
at
com
.webobjects
.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:115)
at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:
1078)
at
com
.webobjects
.appserver
._private.WOComponentReference.invokeAction(WOComponentReference.java:
127)
at
com
.webobjects
.appserver
._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105)
at
com
.webobjects
.appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:115)
at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:
1078)
at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1357)
at
com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:
1736)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._dispatchWithPreparedPage(WOComponentRequestHandler.java:206)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._dispatchWithPreparedSession(WOComponentRequestHandler.java:298)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._dispatchWithPreparedApplication(WOComponentRequestHandler.java:332)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
._handleRequest(WOComponentRequestHandler.java:369)
at
com
.webobjects
.appserver
._private
.WOComponentRequestHandler
.handleRequest(WOComponentRequestHandler.java:442)
at
com
.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:
1678)
at
com
.webobjects
.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144)
at
com
.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:
226)
at java.lang.Thread.run(Thread.java:613)
I assume the "read only entity" is the newly-abstract Person. But I
don't have any Person entities---I've made Person.java an abstract
class. This is at a point where I'm trying to save a UserPreference
whose 'person' relationship points to an AMPerson object.
--
Paul.
w http://logicsquad.net/
h http://paul.hoadley.name/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]