Tuesday, March 4, 2008
Perhaps it was driven by the fact I spent the afternoon at work developing a service event listener for deletion of objects, but I decided to rewrite the way I handle deletion of objects. Earlier I learned, that I do not want to emit the deletion event with the object that I have deleted in it. This prevents the persistence manager from flushing the object out of the cache and leads to synchronization errors later. I am pretty sure this is because of the Strong Reference present within the thread preventing the Entity Manager from flushing. Instead I ended up sending the identity (a Long value) in the PersistenceEvent on the EventBus. The PersistableEvent.getEventClass() would return the class of the object deleted, however when there were a collection of objects (for example, from a multi-object delete) this would be difficult to discern. To this end, I created the class: org.javad.model.EntityReference which supports (currently) the setting of a reference class and an identity. I may eventually add additional status for information about the entity (like whether it is current etc.) however for the deletion case, this was sufficient.
Posted by Jason Drake at 9:48 PM