Reading this forum and documentations i use AbstractTransactionalSpringContextTests to implement dao unit testing
hoping that the test didn't modify the database, this work perfectly in many cases, but for example when i do the following i get problems: I load an entity from DB, then i modify a property and next i go to do a read operation from DB to load a list of objects (including the loaded before) this provoke that hibernate automatically execute an
update over a DB before the reading operation to reflect the changes we made before (the modified property) , when the test finished this modification remain in the DB, In hibernate documentation this can be disable putting in the property FlushMode of the Hibernate Session COMMIT (by default is set to AUTO)
I want to know is how to modify this property from Spring' xml or by code, or if exists other solution to the problem,
here attached the config xml for the test.
Best Regards, Rodney
<beans>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName"><value>org.gjt.mm.mysql.Dri ver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/rdk?autoReconnect=true</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value></value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
<property name="mappingResources">
<list>
<value>common.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.M ySQLDialect</prop>
<prop key="hibernate.query.substitutions">true=1 false=0</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="dataSource"><ref local="dataSource"/></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<bean id="userDao" class="com.rdk.security.persistence.hibernate.User DaoImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
</beans>


Reply With Quote