Re: Saving entities problem [SOLVED]
Re: Saving entities problem [SOLVED]
- Subject: Re: Saving entities problem [SOLVED]
- From: Jevon Hills <email@hidden>
- Date: Tue, 5 Aug 2003 09:07:08 -0600
NOTE: I'm resending this message, as it was returned to me as being too
large. If this is a duplicate I appologize.
------------------------------------------------------------------------
-------------------------------------------------
Ok I did as you instructed below. I believe that I have followed your
instructions to the letter, I'm still getting an exception when I try
to save my changes.
I create a new user.
I save my new user.
No problem. This user is inserted into the database.
I fetch the users from the database and do the following:
aUsers.addObjectToBothSidesOfRelationshipWithKey(mlp,
"FLT_APPLICATIONS");
aUsers.addObjectToBothSidesOfRelationshipWithKey(canUse,
"FLT_PERMISSION");
I then try to save the editing context and get the following stack
trace.
2003-08-01 16:49:44 MDT] <WorkerThread0> Cannot save add AppUserPerm
changes -
[2003-08-01 16:49:44 MDT] <WorkerThread0> Attempt to insert null key
into a com.webobjects.foundation.NSMutableDictionary.
java.lang.IllegalArgumentException: Attempt to insert null key into a
com.webobjects.foundation.NSMutableDictionary.
at
com.webobjects.foundation.NSMutableDictionary.setObjectForKey(NSMutableD
ictionary.java:191)
at
com.webobjects.eoaccess.EODatabaseContext.recordDatabaseOperation(EOData
baseContext.java:4753)
at
com.webobjects.eoaccess.EODatabaseContext.databaseOperationForIntermedia
teRowFromSourceObject(EODatabaseContext.java:4866)
at
com.webobjects.eoaccess.EODatabaseContext.recordInsertForIntermediateRow
FromSourceObject(EODatabaseContext.java:4875)
at
com.webobjects.eoaccess.EODatabaseContext.relayAttributesInRelationshipS
ourceObjectDestinationObject(EODatabaseContext.java:4899)
at
com.webobjects.eoaccess.EODatabaseContext.relayAttributesInRelationshipS
ourceObjectDestinationObjects(EODatabaseContext.java:4952)
at
com.webobjects.eoaccess.EODatabaseContext.recordChangesInEditingContext(
EODatabaseContext.java:6001)
at
com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingCo
ntext(EOObjectStoreCoordinator.java:393)
at
com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.j
ava:2498)
at Main.generateLogins(Main.java:183)
at java.lang.reflect.Method.invoke(Native Method)
at
KeyValueCodingProtectedAccessor.methodValue(KeyValueCodingProtectedAcces
sor.java:24)
at
com.webobjects.foundation.NSKeyValueCoding$_MethodBinding.valueInObject(
NSKeyValueCoding.java:1122)
at
com.webobjects.foundation.NSKeyValueCoding$DefaultImplementation.valueFo
rKey(NSKeyValueCoding.java:1223)
at
com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:1465)
at
com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey(NSKeyValu
eCoding.java:448)
at
com.webobjects.foundation.NSKeyValueCodingAdditions$DefaultImplementatio
n.valueForKeyPath(NSKeyValueCodingAdditions.java:170)
at
com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:15
31)
at
com.webobjects.appserver._private.WOKeyValueAssociation.valueInComponent
(WOKeyValueAssociation.java:46)
at
com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:85)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction(WODynamicG
roup.java:110)
at
com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:877)
at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1020)
at
com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java:1
198)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
hPreparedPage(WOComponentRequestHandler.java:198)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
hPreparedSession(WOComponentRequestHandler.java:279)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWit
hPreparedApplication(WOComponentRequestHandler.java:314)
at
com.webobjects.appserver._private.WOComponentRequestHandler._handleReque
st(WOComponentRequestHandler.java:346)
at
com.webobjects.appserver._private.WOComponentRequestHandler.handleReques
t(WOComponentRequestHandler.java:414)
at
com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.jav
a:1133)
at
com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.
java:158)
at
com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java
:231)
at java.lang.Thread.run(Thread.java:491)
Thank you so much for your assistance and patience with this. It feels
like I'm on the edge of a break through, or maybe a breakdown either
way. It's a long weekend here and I'm taking a break and gonna hit
this hard on Tuesday..
Thanx for everyones help and if you have any suggestions regarding the
stack trace I would love hear from you.
One way to create the correct many-to-many relationship in EOModeler
would be to have it create a many-to-many relationship between User and
Application. Then you'd need to enhance the resulting join entity by
adding another primary key which is the foreign key for the to-one
"permission" relationship. Then you'd add a to-many relationship from
Permission to the join entity whose name should be changed to reflect
its 3-entity join. Flatten the relationships from Permission to both
User and Application. Then you'd carefully set the properties of the 2
new relationships you just created to be identical to those created by
EOModeler when it created a many-to-many relationship between User and
Application.
Then you can decide whether you will really use all the the
relationships between these 4 entities. In relationship sets, if
relationships in both directions are class properties, EOF will usually
fetch more than is necessary to keep the object graph consistent if you
won't be traversing the object graph in both directions. I try to make
a relationship in only one direction a class property to minimize
unnecessary and performance-robbing fetches. This applies to all
relationships, not just many-to-many.
Finally, you'd create a real table in your DB that corresponds to the
join entity using the SQL that EOModeler generates. Or maybe you'd
modify the existing DB join table to reflect the entity ensuring that
the appropriate indexes, constraints, etc. in EOModeler's generated SQL
exist in the DB.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.