How to inject JPA EntityManager using spring

Posted by marcos on Stack Overflow See other posts from Stack Overflow or by marcos
Published on 2010-03-10T23:03:21Z Indexed on 2010/03/14 16:55 UTC
Read the original article Hit count: 413

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about spring

Related posts about jpa