i want to implement a test for the dao classes, but while acting in the same way as in the spring by example (partIII.persistence chapter : Simple Spring Transactional JUnit 4
Test)
the matter is that p:sessionFactory-ref="sessionFactory", because of using the HibernateTemplate instead of SessionFactory.Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <import resource="classpath:WebContent/WEB-INF/DispatcherServlet-servlet.xml"/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" /> <tx:annotation-driven/> <bean id="informationDAO" class="ma.lcaMaroc.domain.dao.hibernate3.InformationDAOImp" p:sessionFactory-ref="sessionFactory" /> </beans>
so here is the "DispatcherServlet-servlet.xml" file:
Code:<flex:message-broker> <flex:remoting-service default-channels="my-amf"/> </flex:message-broker> <context:annotation-config /> <context:component-scan base-package="ma.lcaMaroc"/> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://localhost:3306/lcadb"></property> <property name="username" value="root"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="ma.lcaMaroc" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> </props> </property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- ******DAO************DAO************DAO************DAO************DAO************DAO************DAO****** --> <bean id="informationDAO" class="ma.lcaMaroc.domain.dao.hibernate3.InformationDAOImp" lazy-init="true"> <property name="template" ref="hibernateTemplate" /> </bean>


Reply With Quote
