private Serializable getIdentifier(Object value, SharedSessionContractImplementor session) throws HibernateException { try { return ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName( value ), value, session ); } catch (TransientObjectException toe) { return null; } }
@Override public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache) throws HibernateException { if ( original == null ) { return null; } else { final String entityName = session.bestGuessEntityName( original ); final Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, original, session ); return session.internalLoad( entityName, id, eager, false ); } }
/** * Removes entity entries that have an equal identifier with the incoming entity instance * * @param list The list containing the entity instances * @param entityInstance The entity instance to match elements. * @param entityName The entity name * @param session The session */ public static void identityRemove( Collection list, Object entityInstance, String entityName, SharedSessionContractImplementor session) { if ( entityInstance != null && ForeignKeys.isNotTransient( entityName, entityInstance, null, session ) ) { final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName ); final Type idType = entityPersister.getIdentifierType(); final Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session ); final Iterator itr = list.iterator(); while ( itr.hasNext() ) { final Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, itr.next(), session ); if ( idType.isEqual( idOfCurrent, idOfOld, session.getFactory() ) ) { itr.remove(); break; } } } }
@Override public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException { if ( value == null ) { return null; } else { return new ObjectTypeCacheEntry( session.bestGuessEntityName( value ), ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName( value ), value, session ) ); } }
@Override public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SharedSessionContractImplementor session) throws HibernateException, SQLException { Serializable id; String entityName; if ( value == null ) { id = null; entityName = null; } else { entityName = session.bestGuessEntityName( value ); id = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, value, session ); } // discriminatorType is assumed to be single-column type if ( settable == null || settable[0] ) { discriminatorType.nullSafeSet( st, entityName, index, session ); } if ( settable == null ) { identifierType.nullSafeSet( st, id, index+1, session ); } else { final boolean[] idSettable = new boolean[ settable.length-1 ]; System.arraycopy( settable, 1, idSettable, 0, idSettable.length ); identifierType.nullSafeSet( st, id, index+1, idSettable, session ); } }
final Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, current, final Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session ); if ( !currentIds.contains( useIdDirect ? oldId : new TypedValue( idType, oldId ) ) ) { res.add( old );
@Override public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException { if (value==null) { return null; } else { // cache the actual id of the object, not the value of the // property-ref, which might not be initialized Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session ); if (id==null) { throw new AssertionFailure( "cannot cache a reference to an object with a null id: " + getAssociatedEntityName() ); } return getIdentifierType(session).disassemble(id, session, owner); } }
@Override public Serializable disassemble( Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException { if ( value == null ) { return null; } else { // cache the actual id of the object, not the value of the // property-ref, which might not be initialized Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session ); if ( id == null ) { throw new AssertionFailure( "cannot cache a reference to an object with a null id: " + getAssociatedEntityName() ); } return getIdentifierType( session ).disassemble( id, session, owner ); } }
protected final Object getIdentifier(Object value, SharedSessionContractImplementor session) throws HibernateException { if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) { return ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session ); //tolerates nulls } else if ( value == null ) { return null; } else { EntityPersister entityPersister = getAssociatedEntityPersister( session.getFactory() ); Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName ); // We now have the value of the property-ref we reference. However, // we need to dig a little deeper, as that property might also be // an entity type, in which case we need to resolve its identitifier Type type = entityPersister.getPropertyType( uniqueKeyPropertyName ); if ( type.isEntityType() ) { propertyValue = ( (EntityType) type ).getIdentifier( propertyValue, session ); } return propertyValue; } }
id = ForeignKeys.getEntityIdentifierIfNotUnsaved( foreignValueSourceType.getAssociatedEntityName(), associatedObject,
private Serializable getIdentifier(Object value, SessionImplementor session) throws HibernateException { try { return ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName(value), value, session ); } catch (TransientObjectException toe) { return null; } }
private Serializable getIdentifier(Object value, SessionImplementor session) throws HibernateException { try { return ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName(value), value, session ); } catch (TransientObjectException toe) { return null; } }
private Serializable getIdentifier(Object value, SessionImplementor session) throws HibernateException { try { return ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName(value), value, session ); } catch (TransientObjectException toe) { return null; } }
public static void identityRemove( Collection list, Object object, String entityName, SessionImplementor session) throws HibernateException { if ( object!=null && ForeignKeys.isNotTransient(entityName, object, null, session) ) { final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName ); Type idType = entityPersister.getIdentifierType(); Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, object, session); Iterator itr = list.iterator(); while ( itr.hasNext() ) { Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, itr.next(), session); if ( idType.isEqual( idOfCurrent, idOfOld, session.getFactory() ) ) { itr.remove(); break; } } } }
public static void identityRemove( Collection list, Object object, String entityName, SessionImplementor session) throws HibernateException { if ( object!=null && ForeignKeys.isNotTransient(entityName, object, null, session) ) { final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName ); Type idType = entityPersister.getIdentifierType(); Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, object, session); Iterator itr = list.iterator(); while ( itr.hasNext() ) { Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, itr.next(), session); if ( idType.isEqual( idOfCurrent, idOfOld, session.getFactory() ) ) { itr.remove(); break; } } } }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { return value==null ? null : new ObjectTypeCacheEntry( session.bestGuessEntityName(value), ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName(value), value, session ) ); }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { return value==null ? null : new ObjectTypeCacheEntry( session.bestGuessEntityName(value), ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName(value), value, session ) ); }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { return value==null ? null : new ObjectTypeCacheEntry( session.bestGuessEntityName(value), ForeignKeys.getEntityIdentifierIfNotUnsaved( session.bestGuessEntityName(value), value, session ) ); }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { if ( isNotEmbedded(session) ) { return getIdentifierType(session).disassemble(value, session, owner); } if (value==null) { return null; } else { // cache the actual id of the object, not the value of the // property-ref, which might not be initialized Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session ); if (id==null) { throw new AssertionFailure( "cannot cache a reference to an object with a null id: " + getAssociatedEntityName() ); } return getIdentifierType(session).disassemble(id, session, owner); } }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { if ( isNotEmbedded(session) ) { return getIdentifierType(session).disassemble(value, session, owner); } if (value==null) { return null; } else { // cache the actual id of the object, not the value of the // property-ref, which might not be initialized Object id = ForeignKeys.getEntityIdentifierIfNotUnsaved( getAssociatedEntityName(), value, session ); if (id==null) { throw new AssertionFailure( "cannot cache a reference to an object with a null id: " + getAssociatedEntityName() ); } return getIdentifierType(session).disassemble(id, session, owner); } }