Hibernate interceptor and threading
I have a need to execute some business logic whenever certain domain objects are inserted/updated. The problem is that the business logic is complex and requires several DAOs for read-only data access. Without duplicating logic, how can I utilize these DAOs from within the transaction scope of the interceptor?
I am using HibernateTransactionManager with transaction proxies around my business objects.
1) Does the HibernateTransactionManager support PROPOGATION_REQUIRES_NEW? Will this create another Session for use by the read-only DAOs?
2) Is the Session bound to the current thread? If so, can I execute this business logic in a separate thread? What would I have to do to ensure that this gets executed after the changes to the object have been committed?
In all cases, I want the changes to the object to be persisted to the database just prior to this logic being executed. So I need the following to happen:
1) The changes to the object are committed.
2) If the object was changed, it triggers the additional business logic.
3) The additional logic needs to load related objects, and perhaps the original object itself, so it must be able to see the changes.
4) The additional logic will need to persist changes to the related objects loaded in #3.