use of org.hibernate.cache.spi.UpdateTimestampsCache in project BroadleafCommerce by BroadleafCommerce.
the class UpdateExecutor method executeTargetedCacheInvalidation.
/**
* @param em
* @param entityType
* @param ids
*/
public static void executeTargetedCacheInvalidation(EntityManager em, Class<?> entityType, List<Long> ids) {
Session session = em.unwrap(Session.class);
for (Long id : ids) {
session.getSessionFactory().getCache().evictEntity(entityType, id);
}
// update the timestamp cache for the table so that queries will be refreshed
ClassMetadata metadata = session.getSessionFactory().getClassMetadata(entityType);
String tableName = ((AbstractEntityPersister) metadata).getTableName();
UpdateTimestampsCache timestampsCache = em.unwrap(SessionImplementor.class).getFactory().getUpdateTimestampsCache();
if (timestampsCache != null) {
timestampsCache.invalidate(new Serializable[] { tableName });
}
}
Aggregations