Results 1 to 5 of 5

Thread: Spring 2.1 JPA + EntityManager injection

  1. #1

    Default Spring 2.1 JPA + EntityManager injection

    I am testdriving Spring 2.1 using the new annotations for component configuration.

    So far I've been using PersistenceAnnotationBeanPostProcessor to inject Entitymanager into my DAO's.

    The problem is, that when I configure my DAO's using @Repository or @Component, the EntityManager doesn't get injected.

    When configured inside a regular .xml file, everything is fine.

    Is this the intended behavior?

  2. #2

    Default

    Are you trying to do something like this :

    http://tudu.svn.sourceforge.net/view...80&view=markup

    ??

    If so, it should indeed work. In fact, it works in my application.

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    Are you missing @PersistenceContext? As shown in the example Julien linked to.
    Last edited by karldmoore; Aug 29th, 2007 at 11:16 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  4. #4

    Default

    No, as I've already stated: when configuring the dao from xml: <bean id="..." .../> it works fine.

    When I remove the bean from the xml and use @Repository or @Component instead, the EntityManager is not injected with the @PersistenceContext annotation present

  5. #5
    Join Date
    Aug 2006
    Posts
    2

    Default

    Quote Originally Posted by leetgeezer View Post
    No, as I've already stated: when configuring the dao from xml: <bean id="..." .../> it works fine.

    When I remove the bean from the xml and use @Repository or @Component instead, the EntityManager is not injected with the @PersistenceContext annotation present
    And you remembered to use <context:component-scan .. > and <bean id="foo" class="org.springframework.orm.jpa.support.Persist enceAnnotationBeanPostProcessor"/> .. ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •