cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Nelson <>
Subject Error when adding and then removing object from relationship before committing
Date Wed, 30 Apr 2008 05:04:16 GMT
Let me start this post by thanking the Cayenne dev team for their great work. The project I'm
working on switched from Hibernate to Cayenne several months ago. I can honestly say the decision
to switch is one of the best things that ever happened to my project.

Now on to my problem...

I have a situation where I 

1. Add a newly created object to a relationship. 

        EstimateRoom room = context.newObject(EstimateRoom.class);

        // Several lines configuring variables in room

2. Remove the object from the relationship


3. Attempt to commit to the parent DataContext

This works as long as the object is the last element contained in the List maintaining the
relationship. If it is in the middle of the List(I sort the list after the room is inserted)
I receive the following exception.

[v.3.0M3 Jan 27 2008 20:12:33] Commit Exception
org.apache.cayenne.CayenneRuntimeException: [v.3.0M3 Jan 27 2008 20:12:33] Commit Exception
	at org.apache.cayenne.access.DataContext.flushToParent(
	at org.apache.cayenne.access.DataContext.commitChanges(
	at com.logicalsolutions.estimator.estimate.EstimatePanel.onApply(
	at com.logicalsolutions.estimator.estimate.EstimatePanel.vaidateAndSave(
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at Source)
Caused by: java.lang.NullPointerException: Attempt to add null target DataObject.
	at org.apache.cayenne.CayenneDataObject.addToManyTarget(
	at org.apache.cayenne.access.ChildDiffLoader$1.visitToMany(
	at org.apache.cayenne.access.ChildDiffLoader.arcCreated(
	at org.apache.cayenne.access.ObjectDiff$ArcOperation.apply(
	at org.apache.cayenne.graph.CompoundDiff.apply(
	at org.apache.cayenne.access.ObjectStoreGraphDiff.apply(
	at org.apache.cayenne.access.DataContext.onContextFlush(
	at org.apache.cayenne.access.DataContext.onSync(
	at org.apache.cayenne.access.DataContext.flushToParent(
	... 29 more

So a few questions...
1. Is it OK to sort the Lists that represent the relationships.

2. Is this a known issue with a workaround. Yes I've searched, and searched, and searched
both the
mailing list and JIRA.

3. How do I get more information about what's really going on in Cayenne. Is there a way to
more than what is included in the Exception stack trace.

Any help is very much appreciated!


View raw message