Java Reference
In-Depth Information
Chapter 12
Completing the Stack
Stripes is a very “friendly” framework in the sense that it makes the
integration of third-party libraries quite simple. In this chapter, we'll
look at inviting a few friends to the party: Java Persistence API (JPA),
Hibernate, Spring, and JUnit. We'll store the model data of our webmail
application in a real database, make it easier to swap DAO implemen-
tations by using dependency injection, and write some automated unit
tests.
12.1
Persistence with Stripersist, JPA, and Hibernate
So far, we've been using mock DAOs to store the webmail data. This was
on purpose so that you could focus on learning core aspects of Stripes
without getting distracted by database issues. Now that you've acquired
a considerable amount of Stripes knowledge, it's time to complete the
stack from the model to the database.
You can make the link between Java model objects and a database in
many ways: using plain JDBC, using a library that facilitates the inter-
action with JDBC but places the responsibility of writing SQL on you,
using an Object-Relational Mapping (ORM) framework, and so on. Each
solution has its advantages and disadvantages. I can't possibly demon-
strate every possibility, and I won't debate the pros and cons of each.
Rather, I'll show you an ORM example with JPA and Hibernate. 1 I chose
this combination because JPA is Sun's standard persistence specifica-
tion and because there's a library specifically designed to integrate JPA
These
live
at
and
1.
http://java.sun.com/javaee/technologies/persistence.jsp
http://www.hibernate.org .
 
 
 
 
Search WWH ::




Custom Search