Dashboard > Struts University > Home > MailReader > MailReader Use Cases > dao
Added by Ted Husted, last edited by Ted Husted on Dec 09, 2007
Labels: 
(None)


Brief

The MailReader application manages several persistent objects. Using data access objects (DAOs) can help separate the persistence services from the business serivces.

Narrative

Marvin creates a MessageDao class to see if data access objects will help manage the MailReader code. Spring supports the @PersistenceContext annotation, meaning that an EntityManager can be injected into the DAO.

He starts by taking the existing MessageTestCase and converting the heart of each test to a DAO method. In the end, the MessageDao class has methods like count, create, find, update, delete.

To prove to Ford that all the DAO work, Marvin creates a JUnit test that exercises the DAO operations automatically. Instead of setting up an EntityManager member, the test setUp retrieves the messageDao from a Spring catalog that has been updated to recognize the @PersistenceContext annotation.

Goal

Goal Create, retrieve, update, and delete entity objects.
Level Subfunction (User Goal, Summary, Subfunction)
Trigger System needs to invoke a CRUD operation.
Primary Actor System

Main Success Scenario (MSS)

Step Action
1 Copy MessageTestCase as MessageDao
2 Add an EntityManager setter with a @PersistenceContext annotation
3 Rework MessageDao tests into data access methods that use the manager field
4 Update spring.xml to add an LocalEntityManagerFactoryBean,
PersistenceAnnotationBeanPostProcessor, and MessageDao reference
5 Copy MessageTestCase as MessageDaoTestCase and rework to utilize MessageDao

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