예제 #1
0
        /// <summary>
        /// Evict an entry from the process-level cache.  This method occurs outside
        /// of any transaction; it performs an immediate "hard" remove, so does not respect
        /// any transaction isolation semantics of the usage strategy.  Use with care.
        /// </summary>
        /// <param name="factory">The session factory.</param>
        /// <param name="roleName">Collection role name.</param>
        /// <param name="id">Collection id</param>
        /// <param name="tenantIdentifier">Tenant identifier</param>
        public static void EvictCollection(this ISessionFactory factory, string roleName, object id, string tenantIdentifier)
        {
            if (tenantIdentifier == null)
            {
                factory.EvictCollection(roleName, id);
            }

            ReflectHelper.CastOrThrow <SessionFactoryImpl>(factory, "multi-tenancy").EvictCollection(roleName, id, tenantIdentifier);
        }
예제 #2
0
        public static void ClearSecondLevelCache(ISessionFactory sessionFactory)
        {
            var classMetadata = sessionFactory.GetAllClassMetadata();
            foreach (var ep in classMetadata.Values) {
                sessionFactory.EvictEntity(ep.EntityName);
            }

            var collMetadata = sessionFactory.GetAllCollectionMetadata();
            foreach (var acp in collMetadata.Values) {
                sessionFactory.EvictCollection(acp.Role);
            }
        }
예제 #3
0
 static void ClearCache(ISessionFactory factory)
 {
     factory.EvictQueries();
     foreach (var collectionMetadata in factory.GetAllCollectionMetadata())
     {
         factory.EvictCollection(collectionMetadata.Key);
     }
     foreach (var classMetadata in factory.GetAllClassMetadata())
     {
         factory.EvictEntity(classMetadata.Key);
     }
 }
예제 #4
0
        public static void ClearSecondLevelCache(ISessionFactory sessionFactory)
        {
            var classMetadata = sessionFactory.GetAllClassMetadata();

            foreach (var ep in classMetadata.Values)
            {
                sessionFactory.EvictEntity(ep.EntityName);
            }

            var collMetadata = sessionFactory.GetAllCollectionMetadata();

            foreach (var acp in collMetadata.Values)
            {
                sessionFactory.EvictCollection(acp.Role);
            }
        }
예제 #5
0
 /// <summary>
 /// Evict all entries from the process-level cache. This method occurs outside
 /// of any transaction; it performs an immediate "hard" remove, so does not respect
 /// any transaction isolation semantics of the usage strategy. Use with care.
 /// </summary>
 /// <param name="factory">The session factory.</param>
 /// <param name="roleNames">The names of the collections to evict.</param>
 public static void EvictCollection(this ISessionFactory factory, IEnumerable <string> roleNames)
 {
     if (factory is SessionFactoryImpl sfi)
     {
         sfi.EvictCollection(roleNames);
     }
     else
     {
         if (roleNames == null)
         {
             throw new ArgumentNullException(nameof(roleNames));
         }
         foreach (var role in roleNames)
         {
             factory.EvictCollection(role);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Removes the customer with customerID
        /// </summary>
        /// <param name="CustomerID"></param>
        public void RemoveCustomer(string CustomerID)
        {
            ITransaction tx = null;
            Customer     customer;

            try
            {
                if (!session.IsConnected)
                {
                    session.Reconnect();
                }

                tx = session.BeginTransaction();
                IEnumerator enumerator = session.CreateQuery("select cust " + "from Customer cust where " +
                                                             "cust.CustomerID = '" + CustomerID + "'").Enumerable().GetEnumerator();

                enumerator.MoveNext();
                customer = (Customer)enumerator.Current;
                if (customer != null)
                {
                    session.Delete(customer);
                    factory.Evict(typeof(Customer), CustomerID);
                    factory.EvictCollection(typeof(Customer).ToString() + ".Orders", CustomerID);

                    Console.WriteLine("\nCustomer with ID: " + CustomerID + " succefully deleted from database");
                }
                else
                {
                    Console.WriteLine("No such customer exist.");
                }
                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                session.Clear();
                session.Disconnect();
                throw ex;
                // handle exception
            }
        }
예제 #7
0
        public static void ClearCache(ISessionFactory factory, string region)
        {
            // Libera los tres bloques...
            // TODO: MIGRAR

            /*
             * ICollection types = factory.GetAllClassMetadata().Keys;
             * foreach (Type type in types)
             * factory.Evict(type);*/
            foreach (string role in factory.GetAllCollectionMetadata().Keys)
            {
                factory.EvictCollection(role);
            }
            if (string.IsNullOrEmpty(region))
            {
                factory.EvictQueries();
            }
            else
            {
                factory.EvictQueries(region);
            }
        }
 public void EvictCollection(string roleName) => _inner.EvictCollection(roleName);
예제 #9
0
 public void EvictCollection(string roleName)
 {
     _sessionFactory.EvictCollection(roleName);
 }