-
Jun 5th, 2012, 03:33 AM
#1
About Instances in Spring
Hello all,
I have a simple question in order to do my Junit in right way.(I am newbie on spring)
On my bean application-context.xml i have declare bean.
- dummyTestDao : For my class Junit DummyJpaDao Inherit JpaDaoSupport.(in order to inject on entityManagerFactory my bean dummyEntityManagerFactory configured before)
<bean id="dummyTestDao" class="dummy.service.DummyJpaDao" autowire="byName">
<property name="entityManagerFactory" ref="dummyEntityManagerFactory" />
</bean>
And other one for my service :
<bean id="dummyService" class="dummy.service.DummyJpaDao" autowire="byName">
<property name="entityManagerFactory" ref="dummyEntityManagerFactory" />
</bean>
My transaction manager :
<bean class="org.springframework.orm.jpa.JpaTransactionM anager"
id="dummyTransactionManager">
<property name="entityManagerFactory" ref="dummyEntityManagerFactory" />
</bean>
On my test i use the service to manage my DummyDao and i use dummyService on my Junit in order to only check my data in SGBD. I want to avoid the following case i have before : My context after a persist() throw neither exception and when i read my instance it exist and the Junit was checked, but when I visualise in database the ligne doesn't exist.
So i want to know, is it a good way to do like I have done ?
One more thing : Spring instanciate one or two instance of dummyEntityManagerFactory ?
Thank,
Yoann
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules