Spring框架学习[HibernateTemplate对Hibernate的封装](七)
Strategy = Configuration.class.getMethod( "setCacheConcurrencyStrategy", String.class, String.class, String.class); //通过反射机制调用Hibernate配置对象的setCacheConcurrencyStrategy方法 ReflectionUtils.invokeMethod(setCacheConcurrencyStrategy, config, className, strategyAndRegion[0], strategyAndRegion[1]); } //缓存策略属性值只有一个,则只需设置一个 else if (strategyAndRegion.length > 0) { config.setCacheConcurrencyStrategy(className, strategyAndRegion[0]); } } } //如果Hibernate配置了集合缓存策略 if (this.collectionCacheStrategies != null) { //为映射的集合注册缓存策略 for (Enumeration collRoles = this.collectionCacheStrategies.propertyNames(); collRoles.hasMoreElements();) { String collRole = (String) collRoles.nextElement(); String[] strategyAndRegion = StringUtils.commaDelimitedListToStringArray(this.collectionCacheStrategies.getProperty(collRole)); if (strategyAndRegion.length > 1) { config.setCollectionCacheConcurrencyStrategy(collRole, strategyAndRegion[0], strategyAndRegion[1]); } else if (strategyAndRegion.length > 0) { config.setCollectionCacheConcurrencyStrategy(collRole, strategyAndRegion[0]); } } } //注册Hibernate事件监听器 if (this.eventListeners != null) { for (Map.Entry
entry : this.eventListeners.entrySet()) { //监听事件类型 String listenerType = entry.getKey(); //监听类对象 Object listenerObject = entry.getValue(); //如果监听类对象类型是集合 if (listenerObject instanceof Collection) { Collection