/** * Get our underlying collection persister (using the session to access the * factory). * * @param session The session from which the request is originating. * @return The underlying collection persister */ private CollectionPersister getPersister(SharedSessionContractImplementor session) { return getPersister( session.getFactory() ); }
/** * Is the owning entity versioned? * * @param session The session from which the request is originating. * @return True if the collection owner is versioned; false otherwise. * @throws org.hibernate.MappingException Indicates our persister could not be located. */ private boolean isOwnerVersioned(SharedSessionContractImplementor session) throws MappingException { return getPersister( session ).getOwnerEntityPersister().isVersioned(); }
@Override public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException { //we must use the "remembered" uk value, since it is //not available from the EntityEntry during assembly if (cached==null) { return null; } else { final Serializable key = (Serializable) getPersister(session) .getKeyType() .assemble( cached, session, owner); return resolveKey( key, session, owner, null ); } }
@Override public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException { //remember the uk value //This solution would allow us to eliminate the owner arg to disassemble(), but //what if the collection was null, and then later had elements added? seems unsafe //session.getPersistenceContext().getCollectionEntry( (PersistentCollection) value ).getKey(); final Serializable key = getKeyOfOwner(owner, session); if (key==null) { return null; } else { return getPersister(session) .getKeyType() .disassemble( key, session, owner ); } }
/** * Get the id value from the owning entity key, usually the same as the key, but might be some * other property, in the case of property-ref * * @param key The collection owner key * @param session The session from which the request is originating. * @return The collection owner's id, if it can be obtained from the key; * otherwise, null is returned */ public Serializable getIdOfOwnerOrNull(Serializable key, SharedSessionContractImplementor session) { Serializable ownerId = null; if ( foreignKeyPropertyName == null ) { ownerId = key; } else { Type keyType = getPersister( session ).getKeyType(); EntityPersister ownerPersister = getPersister( session ).getOwnerEntityPersister(); // TODO: Fix this so it will work for non-POJO entity mode Class ownerMappedClass = ownerPersister.getMappedClass(); if ( ownerMappedClass.isAssignableFrom( keyType.getReturnedClass() ) && keyType.getReturnedClass().isInstance( key ) ) { // the key is the owning entity itself, so get the ID from the key ownerId = ownerPersister.getIdentifier( key, session ); } else { // TODO: check if key contains the owner ID } } return ownerId; }
@Override public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException { if ( value == null ) { return "null"; } if ( !getReturnedClass().isInstance( value ) && !PersistentCollection.class.isInstance( value ) ) { // its most likely the collection-key final CollectionPersister persister = getPersister( factory ); if ( persister.getKeyType().getReturnedClass().isInstance( value ) ) { return getRole() + "#" + getPersister( factory ).getKeyType().toLoggableString( value, factory ); } else { // although it could also be the collection-id if ( persister.getIdentifierType() != null && persister.getIdentifierType().getReturnedClass().isInstance( value ) ) { return getRole() + "#" + getPersister( factory ).getIdentifierType().toLoggableString( value, factory ); } } } return renderLoggableString( value, factory ); }
Type keyType = getPersister( session ).getKeyType(); Class returnedClass = keyType.getReturnedClass();
pc.replaceQueuedOperationValues( getPersister( session ), copyCache );
CollectionPersister persister = getPersister( session ); final PersistenceContext persistenceContext = session.getPersistenceContext(); final EntityMode entityMode = persister.getOwnerEntityPersister().getEntityMode();
/** * Is the owning entity versioned? */ private boolean isOwnerVersioned(SessionImplementor session) throws MappingException { return getPersister( session ) .getOwnerEntityPersister() .isVersioned(); }
/** * Is the owning entity versioned? */ private boolean isOwnerVersioned(SessionImplementor session) throws MappingException { return getPersister( session ) .getOwnerEntityPersister() .isVersioned(); }
/** * Is the owning entity versioned? * * @param session The session from which the request is originating. * @return True if the collection owner is versioned; false otherwise. * @throws org.hibernate.MappingException Indicates our persister could not be located. */ private boolean isOwnerVersioned(SessionImplementor session) throws MappingException { return getPersister( session ).getOwnerEntityPersister().isVersioned(); }
/** * Is the owning entity versioned? * * @param session The session from which the request is originating. * @return True if the collection owner is versioned; false otherwise. * @throws org.hibernate.MappingException Indicates our persister could not be located. */ private boolean isOwnerVersioned(SessionImplementor session) throws MappingException { return getPersister( session ).getOwnerEntityPersister().isVersioned(); }
public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { //we must use the "remembered" uk value, since it is //not available from the EntityEntry during assembly if (cached==null) { return null; } else { final Serializable key = (Serializable) getPersister(session) .getKeyType() .assemble( cached, session, owner); return resolveKey( key, session, owner ); } }
public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { //we must use the "remembered" uk value, since it is //not available from the EntityEntry during assembly if (cached==null) { return null; } else { final Serializable key = (Serializable) getPersister(session) .getKeyType() .assemble( cached, session, owner); return resolveKey( key, session, owner ); } }
public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { //we must use the "remembered" uk value, since it is //not available from the EntityEntry during assembly if (cached==null) { return null; } else { final Serializable key = (Serializable) getPersister(session) .getKeyType() .assemble( cached, session, owner); return resolveKey( key, session, owner ); } }
public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { //we must use the "remembered" uk value, since it is //not available from the EntityEntry during assembly if (cached==null) { return null; } else { final Serializable key = (Serializable) getPersister(session) .getKeyType() .assemble( cached, session, owner); return resolveKey( key, session, owner ); } }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { //remember the uk value //This solution would allow us to eliminate the owner arg to disassemble(), but //what if the collection was null, and then later had elements added? seems unsafe //session.getPersistenceContext().getCollectionEntry( (PersistentCollection) value ).getKey(); final Serializable key = getKeyOfOwner(owner, session); if (key==null) { return null; } else { return getPersister(session) .getKeyType() .disassemble( key, session, owner ); } }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { //remember the uk value //This solution would allow us to eliminate the owner arg to disassemble(), but //what if the collection was null, and then later had elements added? seems unsafe //session.getPersistenceContext().getCollectionEntry( (PersistentCollection) value ).getKey(); final Serializable key = getKeyOfOwner(owner, session); if (key==null) { return null; } else { return getPersister(session) .getKeyType() .disassemble( key, session, owner ); } }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { //remember the uk value //This solution would allow us to eliminate the owner arg to disassemble(), but //what if the collection was null, and then later had elements added? seems unsafe //session.getPersistenceContext().getCollectionEntry( (PersistentCollection) value ).getKey(); final Serializable key = getKeyOfOwner(owner, session); if (key==null) { return null; } else { return getPersister(session) .getKeyType() .disassemble( key, session, owner ); } }