|
The problem is that em.persist is not calling the pre-persist callbacks. Hibernate delays the execution of these callbacks until em.flush() is called. Even though this might sound counterintuative initially, it makes more sense if you think about whole object graphs and cascading operations. Flush is when Hibernate ORM identifies all the entities that have been changed and need database actions.
Regarding the spec, it is vague enough in this regards to allow for this behaviour.
|