/** * Intended for test usage. Really has no use-case in Hibernate proper. */ public boolean containsEntityKey(EntityKey key) { if ( key.isBatchLoadable() ) { LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( key.getEntityName()); if ( set != null ) { return set.contains( key ); } } return false; }
/** * After evicting or deleting or loading an entity, we don't * need to batch fetch it anymore, remove it from the queue * if necessary */ public void removeBatchLoadableEntityKey(EntityKey key) { if ( key.isBatchLoadable() ) { LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( key.getEntityName()); if (set != null) { set.remove(key); } } }
/** * If an EntityKey represents a batch loadable entity, add * it to the queue. * <p/> * Note that the contract here is such that any key passed in should * previously have been been checked for existence within the * {@link PersistenceContext}; failure to do so may cause the * referenced entity to be included in a batch even though it is * already associated with the {@link PersistenceContext}. */ public void addBatchLoadableEntityKey(EntityKey key) { if ( key.isBatchLoadable() ) { LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( key.getEntityName()); if (set == null) { set = new LinkedHashSet<>( 8 ); batchLoadableEntityKeys.put( key.getEntityName(), set); } set.add(key); } }
@Override public Object[] getCachedDatabaseSnapshot(EntityKey key) { final Object snapshot = entitySnapshotsByKey.get( key ); if ( snapshot == NO_ROW ) { throw new IllegalStateException( "persistence context reported no row snapshot for " + MessageHelper.infoString( key.getEntityName(), key.getIdentifier() ) ); } return (Object[]) snapshot; }
public void toString(Iterable<Map.Entry<EntityKey, Object>> entitiesByEntityKey) throws HibernateException { if ( !LOG.isDebugEnabled() || !entitiesByEntityKey.iterator().hasNext() ) { return; } LOG.debug( "Listing entities:" ); int i = 0; for ( Map.Entry<EntityKey, Object> entityKeyAndEntity : entitiesByEntityKey ) { if ( i++ > 20 ) { LOG.debug( "More......" ); break; } LOG.debug( toString( entityKeyAndEntity.getKey().getEntityName(), entityKeyAndEntity.getValue() ) ); } }
@Override public void checkUniqueness(EntityKey key, Object object) throws HibernateException { final Object entity = getEntity( key ); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
@Override public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException { checkOpenOrWaitingForAutoClose(); // 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 = getInterceptor().getEntity( key.getEntityName(), key.getIdentifier() ); if ( newObject != null ) { lock( newObject, LockMode.NONE ); } return newObject; } else { return result; } }
final EntityPersister persister = event.getSession() .getFactory() .getEntityPersister( keyToLoad.getEntityName() ); if ( !persister.isInstance( old ) ) { LOG.debug(
/** * Intended for test usage. Really has no use-case in Hibernate proper. */ public boolean containsEntityKey(EntityKey key) { if ( key.isBatchLoadable() ) { LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( key.getEntityName()); if ( set != null ) { return set.contains( key ); } } return false; }
/** * After evicting or deleting or loading an entity, we don't * need to batch fetch it anymore, remove it from the queue * if necessary */ public void removeBatchLoadableEntityKey(EntityKey key) { if ( key.isBatchLoadable() ) { LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( key.getEntityName()); if (set != null) { set.remove(key); } } }
@Override public Object[] getCachedDatabaseSnapshot(EntityKey key) { final Object snapshot = entitySnapshotsByKey.get( key ); if ( snapshot == NO_ROW ) { throw new IllegalStateException( "persistence context reported no row snapshot for " + MessageHelper.infoString( key.getEntityName(), key.getIdentifier() ) ); } return (Object[]) snapshot; }
public void toString(Iterable<Map.Entry<EntityKey,Object>> entitiesByEntityKey) throws HibernateException { if ( ! LOG.isDebugEnabled() || ! entitiesByEntityKey.iterator().hasNext() ) return; LOG.debug( "Listing entities:" ); int i=0; for ( Map.Entry<EntityKey,Object> entityKeyAndEntity : entitiesByEntityKey ) { if (i++>20) { LOG.debug("More......"); break; } LOG.debug( toString( entityKeyAndEntity.getKey().getEntityName(), entityKeyAndEntity.getValue() ) ); } }
public void toString(Iterable<Map.Entry<EntityKey,Object>> entitiesByEntityKey) throws HibernateException { if ( ! LOG.isDebugEnabled() || ! entitiesByEntityKey.iterator().hasNext() ) return; LOG.debug( "Listing entities:" ); int i=0; for ( Map.Entry<EntityKey,Object> entityKeyAndEntity : entitiesByEntityKey ) { if (i++>20) { LOG.debug("More......"); break; } LOG.debug( toString( entityKeyAndEntity.getKey().getEntityName(), entityKeyAndEntity.getValue() ) ); } }
public void toString( Iterable<Map.Entry<EntityKey, Object>> entitiesByEntityKey, SharedSessionContractImplementor session) throws HibernateException { if ( !LOG.isDebugEnabled() || !entitiesByEntityKey.iterator().hasNext() ) { return; } LOG.debug( "Listing entities:" ); int i = 0; for ( Map.Entry<EntityKey, Object> entityKeyAndEntity : entitiesByEntityKey ) { if ( i++ > 20 ) { LOG.debug( "More......" ); break; } LOG.debug( toString( entityKeyAndEntity.getKey().getEntityName(), entityKeyAndEntity.getValue(), session ) ); } }
public static String toLoggableString(EntityKey entityKey) { return toLoggableString( StringHelper.collapse( entityKey.getEntityName() ), entityKey.getKeyValue() ); }
@Override public void checkUniqueness(EntityKey key, Object object) throws HibernateException { final Object entity = getEntity( key ); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
/** * Attempts to check whether the given key represents an entity already loaded within the * current session. * @param object The entity reference against which to perform the uniqueness check. * @throws HibernateException */ @Override public void checkUniqueness(EntityKey key, Object object) throws HibernateException { Object entity = getEntity(key); if ( entity == object ) { throw new AssertionFailure( "object already associated, but no entry was found" ); } if ( entity != null ) { throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() ); } }
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException { errorIfClosed(); // 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; } }
private boolean isCached(EntityKey entityKey, EntityPersister persister) { if ( persister.hasCache() ) { CacheKey key = context.getSession().generateCacheKey( entityKey.getIdentifier(), persister.getIdentifierType(), entityKey.getEntityName() ); return persister.getCacheAccessStrategy().get( key, context.getSession().getTimestamp() ) != null; } return false; }
private boolean isCached(EntityKey entityKey, EntityPersister persister) { if ( persister.hasCache() ) { CacheKey key = context.getSession().generateCacheKey( entityKey.getIdentifier(), persister.getIdentifierType(), entityKey.getEntityName() ); return persister.getCacheAccessStrategy().get( key, context.getSession().getTimestamp() ) != null; } return false; }