List of usage examples for org.hibernate.engine.spi NamedQueryDefinition getCacheRegion
public String getCacheRegion()
From source file:com.googlecode.hibernate.audit.listener.AuditSessionFactoryObserver.java
License:Open Source License
private void updateMetaModel(Session session) { session.flush();// www .j ava2 s. c o m NamedQueryDefinition selectAuditTypeNamedQueryDefinition = ((SessionFactoryImplementor) session .getSessionFactory()).getNamedQuery(HibernateAudit.SELECT_AUDIT_TYPE_BY_CLASS_NAME); NamedQueryDefinition selectAuditTypeFieldNamedQueryDefinition = ((SessionFactoryImplementor) session .getSessionFactory()) .getNamedQuery(HibernateAudit.SELECT_AUDIT_TYPE_FIELD_BY_CLASS_NAME_AND_PROPERTY_NAME); if (selectAuditTypeNamedQueryDefinition.isCacheable() && selectAuditTypeNamedQueryDefinition.getCacheRegion() != null) { session.getSessionFactory().getCache() .evictQueryRegion(selectAuditTypeNamedQueryDefinition.getCacheRegion()); } if (selectAuditTypeFieldNamedQueryDefinition.isCacheable() && selectAuditTypeFieldNamedQueryDefinition.getCacheRegion() != null) { session.getSessionFactory().getCache() .evictQueryRegion(selectAuditTypeFieldNamedQueryDefinition.getCacheRegion()); } session.getSessionFactory().getCache().evictEntityRegion(AuditType.class.getName()); session.getSessionFactory().getCache().evictEntityRegion(AuditTypeField.class.getName()); }