gavin wrote:
Handling the *association* as a (parametrized) UserType does not mean that the actual associatted instances can't be instances of a mapped entity class.
(OTOH, you could also try using Interceptor.getEntity().)
let me create an example:
class1 1->* class2 1->* class3
class2 and 3 are read-only
class1 is read-write
how can i navigate from class2 to class3 having only ONE instances of both?
i can create usertype for class2 so that class1 sees it but what is with navigation to class3?
i have found only one usage of interceptor.getEntity in sources if getEntity returns null. Will it work? Will session not duplicate object after getting it from interseptor.getEntity?
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException {
// todo : should this get moved to PersistentContext?
// logically, is PersistentContext the "thing" to which an interceptor gets attached?
final Object result = persistenceContext.getEntity(key);
if ( result == null ) {
final Object newObject = interceptor.getEntity( key.getEntityName(), key.getIdentifier() );
if ( newObject != null ) lock(newObject, LockMode.NONE);
return newObject;
}
else {
return result;
}
}