Is it possible to have Spring inject the JPA entityManager object into my DAO class without extending JpaDaoSupport? If yes, does Spring m
Is it possible to have spring to inject the JPA entityManager object into my DAO class whitout extending JpaDaoSupport? if yes, does spring manage the transaction in this case?
This is documented black on white in 12.6.3. Implementing DAOs based on plain JPA:
It is possible to write code against the plain JPA without using any Spring dependencies, using an injected
EntityManagerFactoryorEntityManager. Note that Spring can understand@PersistenceUnitand@PersistenceContextannotations both at field and method level if aPersistenceAnnotationBeanPostProcessoris enabled. A corresponding DAO implementation might look like this (...)
And regarding transaction management, have a look at 12.7. Transaction Management:
Spring JPA allows a configured
JpaTransactionManagerto expose a JPA transaction to JDBC access code that accesses the same JDBC DataSource, provided that the registeredJpaDialectsupports retrieval of the underlying JDBC Connection. Out of the box, Spring provides dialects for the Toplink, Hibernate and OpenJPA JPA implementations. See the next section for details on theJpaDialectmechanism.