Hi,
we're migrating a large application from JDO 1 to hibernate 3 and there is still a point we can't easily "translate" from the existing code.
Using JDO, we could use JDOHelper.isPersistent, JDOHelper.isNew, JDOHelper.isDeleted, ... to get the status of a persistent enity.
With Hibernate, it seems like the internal status should be reachable via ((SessionImplementor)session).getPersistenceContext().getEntry(...).getStatus().
But this is non intened for application use as the doc for Status states, unlike the JDOHelper stuff.
I know we can use interceptors to perform actions at transaction completion time for items which are saved or deleted, but it would require to rethink the calling code which expects to know way before the commit that an object is going to be persisted, removed, or is already persistent.
Maybe the best choice would be to use listeners on the SessionFactory to track "manually" the state of the entity.
Any idea ?
Thanks in advance
Olivier
|