Example #1
0
        public object Load(EntityInfo entityInfo)
        {
            object maybeProxy = session.Get(entityInfo.Clazz, entityInfo.Id);

            // TODO: Initialize call and error trapping
            try
            {
                NHibernateUtil.Initialize(maybeProxy);
            }
            catch (Exception e)
            {
                if (LoaderHelper.IsObjectNotFoundException(e))
                {
                    log.Debug("Object found in Search index but not in database: "
                              + entityInfo.Clazz + " wih id " + entityInfo.Id);
                    maybeProxy = null;
                }
                else
                {
                    throw;
                }
            }

            return(maybeProxy);
        }
Example #2
0
        public IList Load(params EntityInfo[] entityInfos)
        {
            // Use load to benefit from the batch-size
            // We don't face proxy casting issues since the exact class is extracted from the index
            foreach (EntityInfo entityInfo in entityInfos) // TODO: Why do this?
            {
                session.Load(entityInfo.Clazz, entityInfo.Id);
            }

            ArrayList result = new ArrayList(entityInfos.Length);

            foreach (EntityInfo entityInfo in entityInfos)
            {
                try
                {
                    object entity = session.Load(entityInfo.Clazz, entityInfo.Id);
                    NHibernateUtil.Initialize(entity);
                    result.Add(entity);
                }
                catch (Exception e)
                {
                    if (LoaderHelper.IsObjectNotFoundException(e))
                    {
                        log.Warn("Object found in Search index but not in database: "
                                 + entityInfo.Clazz + " wih id " + entityInfo.Id);
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(result);
        }
Example #3
0
        private static Boolean IsEntityNotFound(Exception e, EntityInfo entityInfo)
        {
            if (LoaderHelper.IsObjectNotFoundException(e))
            {
                log.Warn("Object found in Search index but not in database: {0} with id {1}", entityInfo.Clazz, entityInfo.Id);
                return(true);
            }

            return(false);
        }