Holger,
I included your test case in Cayenne under the name DataContextEventsTst.
Indeed MySQL fails miserably on attempts to save a null value in a NOT NULL
column. Guess what happens? It quietly saves an empty string ("") instead
of NULL. Can you imagine that!!!
As expected, Sybase and Oracle correctly rollback failed transaction.
But I discovered more issues with EventHandling:
1. [Fixed] Sometimes CommitObserver would not unregister as listener.
Dangling Observer will generate an exception below on subsequent runs with
a totally different DataContext (I don't know why, but after I put
"unregister..." in "finally" the exception stopped):
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:750)
at java.util.HashMap$KeyIterator.next(HashMap.java:786)
at org.objectstyle.cayenne.event.EventManager.postEvent(EventManager.java:177)
at
org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:868)
at
org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:681)
at
org.objectstyle.cayenne.access.DataContextEventsTst.setUp(DataContextEventsTst.java:93)
2. [Fixed] CommitObserver would react on events generated by all other
DataContexts. This doesn't make sense, so I added a check in notification
methods, so that all but the right DataContext will be ignored.
3. [Unfixed] I don't remember if we discussed this before, but EventHandler
(or rather its internal collections) is totally unsynchronized. This really
needs to be addressed, since potentially it is the meeting point for all
the threads in the application. (I really started paying attention to
concurrency issues after working for 6 month with SMS messaging systems :-))
Another consideration. I changed DataContext events default to "off". I am
open for discussion on that and I didn't mean to mess up other's code. My
reasoning is the following:
- by default CayenneDataObjects do not implement
DataObjectTransactionEventListener, so in almost all cases notifications
will not perform any actual work, but will still be generated.
- if a Cayenne based framework decides to implement a common DataObject
superclass, it will be easy to turn it on for all classes by overriding
"setDataContext".
I suggest a User Guide chapter on event handling in Cayenne where we can
describe all these things in greater detail.
Andrus
This archive was generated by hypermail 2.0.0 : Wed Jan 22 2003 - 00:28:35 EST