I've just embarked on a new project where we will be using JPA. One of the issues that I came across in previous projects is the fact that the EJB events are not really usable, because you often need to modify other entities and that is not supported. I've tried to find out if the events are going to be improved in a future JPA spec, but I cannot find an answer. But maybe the guys implementing the reference implementation do.
So: are there JPA entity events planned in a future spec where you can modify / persist / remove other entities?
On 2013-02-26 16:15, James Sutherland wrote:
> I assume this will always be unspecified/provider specific in the Spec.
> Depending on the event, and the modification, it may work.
> EclipseLink also has its own set of SessionEvents and DescriptorEvents.
> Somethings are better done in the application, instead of persistence events.
Too bad. What would be great is that the events would be fired on all entities before they are written to the database. That would allow for changes being made to other entities.
I've initially indeed adopted Eclipse's events to do this, but ended up with an extended entity manager to generate them. Especially cascade remove is something that is hard to do in an application.