Re: NullPointerException when deleting Object

"Jerry W. Walker" <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi, Philipp,

I'm not sure what's going on, exactly, but it seems that the object,  
EO1, that you've deleted and are currently doing an ec.save changes  
on, has a to many relationship, R, to another object, EO2, that EOF  
is following. R points to an array fault which EOF is firing to get  
to the objects on the other side of R in order to effect a "nullify  
on delete" rule on EO2.

In doing so, it looks like EOF has encountered a many-to-many  
relationship (or, perhaps, a flattened relationship) that it has to  
follow through a join table (or intermediate flattened object's table).

In order to effect the join to get to EO2 on the other side of R, EOF  
is in the midst of creating a SQL SELECT statement for the join and  
is looking for, or creating, an alias for the related attribute's  
relationship path. In its attempt to do so, it concatenates two  
NSStrings and one of those strings (a relationship or attribute name,  
perhaps) is null.

I've presumed a lot in that description and people on the list who  
know EOF's underbelly better than I can probably give you a more  
accurate description. However, if what I've described is at all  
accurate, then you've got a problem in your EOModel, probably with a  
many-to-many relationship off EO1 that you're trying to delete. This  
relationship has been marked with a nullify on delete rule on the EO1  
side, and it seems that one side or the other of that relationship  
has a name problem. Perhaps it's the table name of one or the other  
of the tables on each side of the relationship, or the relationship  
name on one side or the other.

I've done a lot of guessing here, so take what I've offered with many  
grains of salt and apply it only in lieu of any better guesses. In  
particular, if this suggests anything to you, look not only at the  
EOModel in the areas that match my description, but the underlying  
plist tables supporting the model as well. It's been my experience  
that EOModeler doesn't always accurately reflect the contents of  
those plists in the EOModel that it displays.

HTH.

Regards,
Jerry


On May 25, 2006, at 11:39 AM, Philipp Leusmann wrote:

> Hi all,
>
> I have a strange problem with an Application I have to fix.
> I have a list of objects derived from EOGenericRecord which have  
> several
> Relationships. Whenn I call editingContext.deleteObject(o) and
> editingContext.saveChanges() I get a NullPointerException. The  
> important
> part of the stack trace is pasted below.
> Now, when I call the list of the objects again, and try to delete  
> the Object
> once more, it works.
> Can anyone help me with this Problem? Would be great if anybody has  
> an idea.
>
> Thanks,
>  Philipp
>
>
> java.lang.NullPointerException
> at
> com.webobjects.foundation._NSStringUtilities.concat 
> (_NSStringUtilities.java:
> 213)
> 	at
> com.webobjects.eoaccess.EOSQLExpression._aliasForRelatedAttributeRelat 
> ionshi
> pPath(EOSQLExpression.java:264)
> 	at
> com.webobjects.eoaccess.EOSQLExpression.joinExpression 
> (EOSQLExpression.java:
> 1168)
> 	at
> com.webobjects.eoaccess.EOSQLExpression.prepareSelectExpressionWithAtt 
> ribute
> s(EOSQLExpression.java:1033)
> 	at
> com.webobjects.jdbcadaptor.JDBCExpression.prepareSelectExpressionWithA 
> ttribu
> tes(JDBCExpression.java:273)
> 	at
> com.webobjects.eoaccess.EOSQLExpressionFactory.selectStatementForAttri 
> butes(
> EOSQLExpressionFactory.java:219)
> 	at
> com.webobjects.jdbcadaptor.JDBCChannel.selectAttributes 
> (JDBCChannel.java:178
> )
> 	at
> com.webobjects.eoaccess.EODatabaseChannel._selectWithFetchSpecificatio 
> nEditi
> ngContext(EODatabaseChannel.java:879)
> 	at
> com.webobjects.eoaccess.EODatabaseChannel.selectObjectsWithFetchSpecif 
> icatio
> n(EODatabaseChannel.java:216)
> 	at
> com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificati 
> onEdit
> ingContext(EODatabaseContext.java:3206)
> 	at
> com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecificatio 
> n(EODa
> tabaseContext.java:3347)
> 	at
> com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpec 
> ificat
> ion(EOObjectStoreCoordinator.java:539)
> 	at
> com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecificatio 
> n(EOEd
> itingContext.java:4075)
> 	at
> com.webobjects.eoaccess.EODatabaseContext.objectsForSourceGlobalID 
> (EODatabas
> eContext.java:4261)
> 	at
> com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsForSourceGlob 
> alID(E
> OObjectStoreCoordinator.java:682)
> 	at
> com.webobjects.eocontrol.EOEditingContext.objectsForSourceGlobalID 
> (EOEditing
> Context.java:3926)
> 	at
> com.webobjects.eoaccess.EODatabaseContext._fireArrayFault 
> (EODatabaseContext.
> java:4428)
> 	at
> com.webobjects.eoaccess.EOAccessArrayFaultHandler.completeInitializati 
> onOfOb
> ject(EOAccessArrayFaultHandler.java:70)
> 	at
> com.webobjects.eocontrol._EOCheapCopyMutableArray.willRead 
> (_EOCheapCopyMutab
> leArray.java:38)
> 	at
> com.webobjects.eocontrol._EOCheapCopyMutableArray.count 
> (_EOCheapCopyMutableA
> rray.java:92)
> 	at
> com.webobjects.eocontrol._EOCheapCopyArray._setArray 
> (_EOCheapCopyArray.java:
> 60)
> 	at
> com.webobjects.eoaccess._EOCheapCopyHandler.completeInitializationOfOb 
> ject(E
> OAccessArrayFaultHandler.java:151)
> 	at
> com.webobjects.eocontrol._EOCheapCopyArray.willRead 
> (_EOCheapCopyArray.java:3
> 2)
> 	at
> com.webobjects.eocontrol._EOCheapCopyArray.count 
> (_EOCheapCopyArray.java:87)
> 	at
> com.webobjects.eoaccess.EODatabaseContext.nullifyAttributesInRelations 
> hipSou
> rceObjectDestinationObjects(EODatabaseContext.java:5165)
> 	at
> com.webobjects.eoaccess.EODatabaseContext.recordChangesInEditingContex 
> t(EODa
> tabaseContext.java:6056)
> 	at
> com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditing 
> Contex
> t(EOObjectStoreCoordinator.java:412)
> 	at
> com.webobjects.eocontrol.EOEditingContext.saveChanges 
> (EOEditingContext.java:
> 3187)
> [...]
>
>
>
>
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev


--
__ Jerry W. Walker,
    WebObjects Developer/Instructor for High Performance Industrial  
Strength Internet Enabled Systems

     [email protected]
     203 278-4085        office
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.