@SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory){
  if (configurableListableBeanFactory.containsBean(sessionFactoryBeanName)) {
    BeanDefinition sessionFactoryBeanDefinition=configurableListableBeanFactory.getBeanDefinition(sessionFactoryBeanName);
    MutablePropertyValues propertyValues=sessionFactoryBeanDefinition.getPropertyValues();
    if (mappingResources != null) {
      PropertyValue propertyValue=propertyValues.getPropertyValue("mappingResources");
      if (propertyValue == null) {
        propertyValue=new PropertyValue("mappingResources",new ArrayList());
        propertyValues.addPropertyValue(propertyValue);
      }
      List existingMappingResources=(List)propertyValue.getValue();
      existingMappingResources.addAll(mappingResources);
    }
    if (annotatedClasses != null) {
      PropertyValue propertyValue=propertyValues.getPropertyValue("annotatedClasses");
      if (propertyValue == null) {
        propertyValue=new PropertyValue("annotatedClasses",new ArrayList());
        propertyValues.addPropertyValue(propertyValue);
      }
      List existingMappingResources=(List)propertyValue.getValue();
      existingMappingResources.addAll(annotatedClasses);
    }
    if (configLocations != null) {
      PropertyValue propertyValue=propertyValues.getPropertyValue("configLocations");
      if (propertyValue == null) {
        propertyValue=new PropertyValue("configLocations",new ArrayList());
        propertyValues.addPropertyValue(propertyValue);
      }
      List existingConfigLocations=(List)propertyValue.getValue();
      existingConfigLocations.addAll(configLocations);
    }
    if (hibernateProperties != null) {
      PropertyValue propertyValue=propertyValues.getPropertyValue("hibernateProperties");
      if (propertyValue == null) {
        propertyValue=new PropertyValue("hibernateProperties",new Properties());
        propertyValues.addPropertyValue(propertyValue);
      }
      Properties existingHibernateProperties=(Properties)propertyValue.getValue();
      existingHibernateProperties.putAll(hibernateProperties);
    }
  }
 else {
    throw new NoSuchBeanDefinitionException("No bean named [" + sessionFactoryBeanName + "] exists within the bean factory. "+ "Cannot post process session factory to add Hibernate resource definitions.");
  }
}

@ SuppressWarnings ( "unchecked" ) public void postProcessBeanFactory ( ConfigurableListableBeanFactory configurableListableBeanFactory ) { if ( configurableListableBeanFactory . containsBean ( sessionFactoryBeanName ) ) { BeanDefinition sessionFactoryBeanDefinition = configurableListableBeanFactory . getBeanDefinition ( sessionFactoryBeanName ) ; MutablePropertyValues propertyValues = sessionFactoryBeanDefinition . getPropertyValues ( ) ; if ( mappingResources != null ) { PropertyValue propertyValue = propertyValues . getPropertyValue ( "mappingResources" ) ; if ( propertyValue == null ) { propertyValue = new PropertyValue ( "mappingResources" , new ArrayList ( ) ) ; propertyValues . addPropertyValue ( propertyValue ) ; } List existingMappingResources = ( List ) propertyValue . getValue ( ) ; existingMappingResources . addAll ( mappingResources ) ; } if ( annotatedClasses != null ) { PropertyValue propertyValue = propertyValues . getPropertyValue ( "annotatedClasses" ) ; if ( propertyValue == null ) { propertyValue = new PropertyValue ( "annotatedClasses" , new ArrayList ( ) ) ; propertyValues . addPropertyValue ( propertyValue ) ; } List existingMappingResources = ( List ) propertyValue . getValue ( ) ; existingMappingResources . addAll ( annotatedClasses ) ; } if ( configLocations != null ) { PropertyValue propertyValue = propertyValues . getPropertyValue ( "configLocations" ) ; if ( propertyValue == null ) { propertyValue = new PropertyValue ( "configLocations" , new ArrayList ( ) ) ; propertyValues . addPropertyValue ( propertyValue ) ; } List existingConfigLocations = ( List ) propertyValue . getValue ( ) ; existingConfigLocations . addAll ( configLocations ) ; } if ( hibernateProperties != null ) { PropertyValue propertyValue = propertyValues . getPropertyValue ( "hibernateProperties" ) ; if ( propertyValue == null ) { propertyValue = new PropertyValue ( "hibernateProperties" , new Properties ( ) ) ; propertyValues . addPropertyValue ( propertyValue ) ; } Properties existingHibernateProperties = ( Properties ) propertyValue . getValue ( ) ; existingHibernateProperties . putAll ( hibernateProperties ) ; } } else { throw new NoSuchBeanDefinitionException ( "No bean named [" + sessionFactoryBeanName + "] exists within the bean factory. " + "Cannot post process session factory to add Hibernate resource definitions." ) ; } }
adds the annotated classes and the mapping resources to the existing session factory configuration .
