I created the sessionFactory bean with an org.springframework.orm.hibernate4.LocalSessionFactoryBean class and the transactionManager bean with an org.springframework.orm.hibernate4.HibernateTransactionManager class.
On performing the JUnits tests the following shows up.
" Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.hibernate.SessionFactory' for property 'sessionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found".
The Hibernate Core dependency version is 4.3.9 .
Please advice.
Below is my datasource.xml for the JUnit tests. The tests run under the dev profile. While the exact .xml code runs under the production profile for the main app smoothly.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<context:component-scan base-package="com.caveofprogramming.spring.test">
</context:component-scan>
enter code here
<beans profile="dev">`enter code here`
<context:property-placeholder
location="com/caveofprogramming/spring/web/test/config/jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="username" value="${jdbc.username}"></property>
</bean>
<!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="javax.persistence.validation.group.pre-persist">
com.caveofprogramming.spring.web.dao.PersistenceValidationGroup
</prop>
<prop key="javax.persistence.validation.group.pre-update">
com.caveofprogramming.spring.web.dao.PersistenceValidationGroup
</prop>
<prop key="javax.persistence.validation.group.pre-remove">
com.caveofprogramming.spring.web.dao.PersistenceValidationGroup
</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.caveofprogramming.spring.web.dao</value>
</list>
</property>
</bean>
<!-- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="dataSource" ref="dataSource"></property>
<property name="sessionFactory" value="sessionFactory"></property>
</bean>
<tx:annotation-driven />
<bean id="exceptionTranslator"
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor">
</bean>
</beans>
</beans>