How to inject JPA EntityManager using spring
- by marcos
Hello all!
I have a few questions about jpa + spring integration running on tomcat, i've been looking fo some time and couldn't find any concrete answer, so here it goes:
Is it possible to have spring to inject the JPA entityManager object into my DAO class without extending JpaDaoSupport? if yes, does spring manage the transaction in this case?
I'm trying to keep spring configuration as simple as possible:
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="em"/>
</bean>
<bean id="em" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="myPU"/>
</bean>
EDIT: that was very helpfull, thank you all!