configurableListableBeanFactory.getBeanDefinition(sessionFactoryBeanName);
MutablePropertyValues propertyValues = sessionFactoryBeanDefinition.getPropertyValues();
if (mappingResources != null) {
// do we have existing resourses?
PropertyValue propertyValue = propertyValues.getPropertyValue("mappingResources");
if (propertyValue == null) {
propertyValue = new PropertyValue("mappingResources", new ArrayList());
propertyValues.addPropertyValue(propertyValue);
}
// value is expected to be a list.
List existingMappingResources = (List) propertyValue.getValue();
existingMappingResources.addAll(mappingResources);
}
if (annotatedClasses != null) {
// do we have existing resources?
PropertyValue propertyValue = propertyValues.getPropertyValue("annotatedClasses");
if (propertyValue == null) {
propertyValue = new PropertyValue("annotatedClasses", new ArrayList());
propertyValues.addPropertyValue(propertyValue);
}
// value is expected to be a list.
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. "