Hi

Not sure if I got it right. I presumed if this is a many-to-many modelling between Employee and Turn, and the relationship is flattened.

The way I think it should do to add Employee to Turn and Turn to Employee are as the following:
       localEmployee.addToTurns(actualTurn);
       actualTurn.addToEmployees(localEmployee);

Then call your save changes. Usually there is no need to addBothSideRelationshipWithKey to join table e.g. EmployeeXTurn (presumed again this is join table).

The other thing thought may be useful to check is "propogate primary key" is ticked between the Employee and its relationship to join table, vice versa between Turn and its relationship to join table.

HTH

Cheong Hee

------------------------------

Message: 6
Date: Wed, 15 Oct 2008 23:11:16 -0500
From: WebObjects <[EMAIL PROTECTED]>
Subject: I dont get it, still nullpointer exception
To: WebObjects-Dev Apple <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

Hello, I fixed (or thought I did) the EOmodel, then I did this in my
method.
Employee localEmployee =
(Employee)EOUtilities.localInstanceOfObject(myEC, emp);
System.out.println(selectedItems());


NSArray<Turn> localSelectedItems =
EOUtilities.localInstancesOfObjects(myEC, selectedItems());
EmployeeXTurn empxTurn = (EmployeeXTurn)
ERXEOControlUtilities.createAndInsertObject(myEC,"EmployeeXTurn");
for (Turn actualTurn:localSelectedItems){
actualTurn.addToEmployeeXTurn(empxTurn);
}
System.out.println(localSelectedItems);

empxTurn.addObjectToBothSidesOfRelationshipWithKey(localEmployee,
EmployeeXTurn.EMPLOYEE_KEY);
inside the for I have tried the
addObjectToBothSidesOfRelationshipWithKey() method and the
addObjectsToBothSidesOfRelationshipWithKey() method and im still
getting this error

java.lang.NullPointerException
at
com
.webobjects
.eoaccess
.EODatabaseContext
._objectFaultWithSnapshotRelationshipEditingContext
(EODatabaseContext.java:2356)
at
com
.webobjects
.eoaccess
.EODatabaseContext
._fireDeferredFaultWithSourceObject(EODatabaseContext.java:2401)
at
com
.webobjects
.eoaccess
.EOAccessDeferredFaultHandler
.createFaultForDeferredFault(EOAccessDeferredFaultHandler.java:49)
at
com
.webobjects
.eocontrol.EOCustomObject.willReadRelationship(EOCustomObject.java:1279)
at
er
.extensions
.eof.ERXGenericRecord.willReadRelationship(ERXGenericRecord.java:348)
at com.webobjects.eocontrol._EOMutableKnownKeyDictionary$Initializer
$
_LazyGenericRecordBinding
.valueInObject(_EOMutableKnownKeyDictionary.java:614)
at
com
.webobjects
.eocontrol.EOCustomObject.storedValueForKey(EOCustomObject.java:1634)
at
com
.webobjects
.eoaccess
.EODatabaseContext.databaseOperationForObject(EODatabaseContext.java:
4814)
at
com
.webobjects
.eoaccess.EODatabaseContext.valuesForKeys(EODatabaseContext.java:6535)
at
com
.webobjects
.eocontrol
.EOObjectStoreCoordinator.valuesForKeys(EOObjectStoreCoordinator.java:
326)
at com.webobjects.eoaccess.EOQualifierSQLGeneration
$
_KeyValueQualifierSupport
.schemaBasedQualifierWithRootEntity(EOQualifierSQLGeneration.java:439)
at er.extensions.ERXExtensions
$
KeyValueQualifierSQLGenerationSupport
.schemaBasedQualifierWithRootEntity(ERXExtensions.java:304)
at com.webobjects.eoaccess.EOQualifierSQLGeneration
$
Support
._schemaBasedQualifierWithRootEntity(EOQualifierSQLGeneration.java:179)
at
com
.webobjects
.eoaccess
.EODatabaseChannel
.selectObjectsWithFetchSpecification(EODatabaseChannel.java:227)
at
com
.webobjects
.eoaccess
.EODatabaseContext
._objectsWithFetchSpecificationEditingContext(EODatabaseContext.java:
3055)
at
com
.webobjects
.eoaccess
.EODatabaseContext
.objectsWithFetchSpecification(EODatabaseContext.java:3195)
if I just do this :
empxTurn.addObjectToBothSidesOfRelationshipWithKey(localEmployee,
EmployeeXTurn.EMPLOYEE_KEY);

or this :
localEmployee.addObjectToBothSidesOfRelationshipWithKey(empxTurn,
Employee.EMPLOYEE_X_TURNS_KEY);
all its fine, I can add the employee to the EmployeeXTurn, btu the
problem comes when adding the turn to the EmployeeXTurn.
I think you guys are getting tired of this problems Im having, also I
am, can get it why Im having them.

any clues?

Gus








-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/pipermail/webobjects-dev/attachments/20081015/0c2118ed/attachment.html

------------------------------

_______________________________________________
Webobjects-dev mailing list
[email protected]
http://lists.apple.com/mailman/listinfo/webobjects-dev

End of Webobjects-dev Digest, Vol 5, Issue 1007
***********************************************



_______________________________________________
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]

Reply via email to