Code example for SessionImplementor

Methods: getFactory

0
			if ( !updateable[ props[i] ] ) { 
				allNatualIdPropsAreUpdateable = false; 
				break; 
			} 
		} 
 
		if ( allNatualIdPropsAreUpdateable ) { 
			// do this when all the properties are updateable since there is 
			// a certain likelihood that the information will already be 
			// snapshot-cached. 
			Object[] entitySnapshot = getDatabaseSnapshot( id, persister ); 
			if ( entitySnapshot == NO_ROW ) { 
				return null; 
			} 
			Object[] naturalIdSnapshot = new Object[ props.length ]; 
			for ( int i = 0; i < props.length; i++ ) { 
				naturalIdSnapshot[i] = entitySnapshot[ props[i] ]; 
			} 
			return naturalIdSnapshot; 
		} 
		else { 
			return persister.getNaturalIdentifierSnapshot( id, session ); 
		} 
	} 
 
	/** 
	 * Retrieve the cached database snapshot for the requested entity key. 
	 * <p/> 
	 * This differs from {@link #getDatabaseSnapshot} is two important respects:<ol> 
	 * <li>no snapshot is obtained from the database if not already cached</li> 
	 * <li>an entry of {@link #NO_ROW} here is interpretet as an exception</li> 
	 * </ol> 
	 * @param key The entity key for which to retrieve the cached snapshot 
	 * @return The cached snapshot 
	 * @throws IllegalStateException if the cached snapshot was == {@link #NO_ROW}. 
	 */ 
	public Object[] getCachedDatabaseSnapshot(EntityKey key) { 
		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 removeDatabaseSnapshot(EntityKey key) { 
		entitySnapshotsByKey.remove(key); 
	}*/ 
 
	public void addEntity(EntityKey key, Object entity) { 
		entitiesByKey.put(key, entity); 
		getBatchFetchQueue().removeBatchLoadableEntityKey(key); 
	} 
 
	/** 
	 * Get the entity instance associated with the given 
	 * <tt>EntityKey</tt> 
	 */ 
	public Object getEntity(EntityKey key) { 
		return entitiesByKey.get(key); 
	} 
 
	public boolean containsEntity(EntityKey key) { 
		return entitiesByKey.containsKey(key); 
	} 
 
	/** 
	 * Remove an entity from the session cache, also clear 
	 * up other state associated with the entity, all except 
	 * for the <tt>EntityEntry</tt> 
	 */ 
	public Object removeEntity(EntityKey key) { 
		Object entity = entitiesByKey.remove(key); 
		Iterator iter = entitiesByUniqueKey.values().iterator(); 
		while ( iter.hasNext() ) { 
			if ( iter.next()==entity ) iter.remove(); 
		} 
		// Clear all parent cache 
		parentsByChild.clear(); 
		entitySnapshotsByKey.remove(key); 
		nullifiableEntityKeys.remove(key); 
		getBatchFetchQueue().removeBatchLoadableEntityKey(key); 
		getBatchFetchQueue().removeSubselect(key); 
		return entity; 
	} 
 
	/** 
	 * Get an entity cached by unique key 
	 */ 
	public Object getEntity(EntityUniqueKey euk) { 
		return entitiesByUniqueKey.get(euk); 
	} 
 
	/** 
	 * Add an entity to the cache by unique key 
	 */ 
	public void addEntity(EntityUniqueKey euk, Object entity) { 
		entitiesByUniqueKey.put(euk, entity); 
	} 
 
	/** 
	 * Retreive the EntityEntry representation of the given entity. 
	 * 
	 * @param entity The entity for which to locate the EntityEntry. 
	 * @return The EntityEntry for the given entity. 
	 */ 
	public EntityEntry getEntry(Object entity) { 
		return (EntityEntry) entityEntries.get(entity); 
	} 
 
	/** 
	 * Remove an entity entry from the session cache 
	 */ 
	public EntityEntry removeEntry(Object entity) { 
		return (EntityEntry) entityEntries.remove(entity); 
	} 
 
	/** 
	 * Is there an EntityEntry for this instance? 
	 */ 
	public boolean isEntryFor(Object entity) { 
		return entityEntries.containsKey(entity); 
	} 
 
	/** 
	 * Get the collection entry for a persistent collection 
Contextual code suggestions in your IDE  Get Codota for Java