public object Assemble(object cached, ISessionImplementor session, object owner) { IList srcList = (IList)cached; ArrayList result = new ArrayList(); for (int i = 0; i < assemblersList.Count; i++) { ICacheAssembler[] assemblers = (ICacheAssembler[])assemblersList[i]; IList queryFromCache = (IList)srcList[i]; ArrayList queryResults = new ArrayList(); foreach (object fromCache in queryFromCache) { if (assemblers.Length == 1) { queryResults.Add(assemblers[0].Assemble(fromCache, session, owner)); } else { queryResults.Add(TypeFactory.Assemble((object[])fromCache, assemblers, session, owner)); } } result.Add(queryResults); } return(result); }
private static object[] Assemble(object[] values, object result, object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session) { //assembled state gets put in a new array (we read from cache by value!) object[] assembledProps = TypeFactory.Assemble(values, persister.PropertyTypes, session, result); //from h3.2 TODO: reuse the PreLoadEvent PreLoadEvent preLoadEvent = new PreLoadEvent((IEventSource)session); preLoadEvent.Entity = result; preLoadEvent.State = assembledProps; preLoadEvent.Id = id; preLoadEvent.Persister = persister; IPreLoadEventListener[] listeners = session.Listeners.PreLoadEventListeners; for (int i = 0; i < listeners.Length; i++) { listeners[i].OnPreLoad(preLoadEvent); } persister.SetPropertyValues(result, assembledProps, session.EntityMode); return(assembledProps); }
public IList Get(QueryKey key, IType[] returnTypes, ISet spaces, ISessionImplementor session) { if (log.IsDebugEnabled) { log.Debug("checking cached query results in region: " + regionName); } IList cacheable = ( IList )queryCache.Get(key); if (cacheable == null) { log.Debug("query results were not found in cache"); return(null); } IList result = new ArrayList(cacheable.Count - 1); long timestamp = ( long )cacheable[0]; log.Debug("Checking query spaces for up-to-dateness [" + spaces + "]"); if (!IsUpToDate(spaces, timestamp)) { log.Debug("cached query results were not up to date"); return(null); } log.Debug("returning cached query results"); for (int i = 1; i < cacheable.Count; i++) { if (returnTypes.Length == 1) { result.Add(returnTypes[0].Assemble(cacheable[i], session, null)); } else { result.Add(TypeFactory.Assemble(( object[] )cacheable[i], returnTypes, session, null)); } } return(result); }
public IList Get(QueryKey key, ICacheAssembler[] returnTypes, bool isNaturalKeyLookup, ISet <string> spaces, ISessionImplementor session) { if (log.IsDebugEnabled) { log.DebugFormat("checking cached query results in region: '{0}'; {1}", regionName, key); } var cacheable = (IList)queryCache.Get(key); if (cacheable == null) { log.DebugFormat("query results were not found in cache: {0}", key); return(null); } var timestamp = (long)cacheable[0]; if (log.IsDebugEnabled) { log.DebugFormat("Checking query spaces for up-to-dateness [{0}]", StringHelper.CollectionToString((ICollection)spaces)); } if (!isNaturalKeyLookup && !IsUpToDate(spaces, timestamp)) { log.DebugFormat("cached query results were not up to date for: {0}", key); return(null); } log.DebugFormat("returning cached query results for: {0}", key); for (int i = 1; i < cacheable.Count; i++) { if (returnTypes.Length == 1) { returnTypes[0].BeforeAssemble(cacheable[i], session); } else { TypeFactory.BeforeAssemble((object[])cacheable[i], returnTypes, session); } } IList result = new List <object>(cacheable.Count - 1); for (int i = 1; i < cacheable.Count; i++) { try { if (returnTypes.Length == 1) { result.Add(returnTypes[0].Assemble(cacheable[i], session, null)); } else { result.Add(TypeFactory.Assemble((object[])cacheable[i], returnTypes, session, null)); } } catch (UnresolvableObjectException) { if (isNaturalKeyLookup) { //TODO: not really completely correct, since // the UnresolvableObjectException could occur while resolving // associations, leaving the PC in an inconsistent state log.Debug("could not reassemble cached result set"); queryCache.Remove(key); return(null); } throw; } } return(result); }