| There is a difference in that in the non-enhanced case there is a difference between the entity (instance) and the ManagedEntity. Keep in mind that the (Stateful)PersistenceContext owns the EntityEntryContext. In the case of a non-enhanced entity, for the call to StatefulPersistenceContext#getEntry(Object entity) we can cycle through the EntityEntryContext#nonEnhancedEntityXref to find the ManagedEntity corresponding to the given entity instance; if we do not find one, we know for certain that that entity is not associated with this PC. In the case of an enhanced entity, aside from cycling through the entire linked list of all ManagedEntities for the entire PC we have no such corollary since neither ManagedEntity nor EntityEntry (since y'alls change) keep track of the PC. This is really a problem of misusing something (EntityEntry) based on its design. |