Dashboard > Struts University > Home > JPA Training Course > JPA Agenda > dao-Notes
Added by Ted Husted, last edited by Ted Husted on Dec 09, 2007

Presentation - JUnit Jumpstart

JPA support is easy to hard-code into an application. Spring provides support for injecting JPA support into an application, which can simplify finely-grained transaction management and other advanced features.

  • How can we manage complex transactions?
  • Can we abstract DAO and ORM?
  • What about scheduling? email? security?

Workshop - dao

In the lab, we implement a MessageDAO and MessageService using the Spring JPA template.

  • Create a data access object using Spring's support for the @PersistenceContext annotation


  • Message
  • MessageTestCase
  • spring.xml and boostrap code

New Dependencies

  • LocalEntityManagerFactoryBean
  • PersistenceAnnotationBeanPostProcessor


  • Create a MessageDao class that simplifies the MessageTestCase
  • Create a new TestCase for the MessageDao class

Hint Code

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean" />
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    <bean id="messageDao" class="demo.MessageDao"/>
factory = new XmlBeanFactory(new ClassPathResource("spring.xml"));
    messageDao = (MessageDao) factory.getBean("messageDao");


  • Created a data access object using Spring's support for the @PersistenceContext annotation

Site running on a free Atlassian Confluence Open Source Project License granted to OSS. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators