Java Reference
In-Depth Information
with Stripes. Now, since JPA is only a specification, you also need an
implementation; I chose Hibernate because it's widely used. I don't use
anything Hibernate-specific in the sample code, so things should work
the same if you decided to replace Hibernate with any other JPA imple-
mentation, such as OpenJPA ( http://openjpa.apache.org ) or JPOX ( http://
www.jpox.org ) .
Aaron Porter, Stripes committer, smart developer, and all-around nice
guy, wrote a library that facilitates the integration of JPA in Stripes,
named Stripersist. 2 Crack your knuckles, we're going to set up a data-
base and use JPA, Hibernate, and Stripersist to implement the persis-
tence of the webmail application model data.
Setting Up a Database
Of course, we'll need a database to get started. Any database that has
a JDBC driver will do, such as Postgres ( http://www.postgresql.com ) and
MySQL ( http://www.mysql.com ) . If you're using a commercial database,
chances are that they provide a JDBC driver as well.
I use HSQLDB ( http://www.hsqldb.org ) for the sample application because
setting it up is extremely simple. I also like that it comes with a GUI
so that you can browse the database and poke around. If you have
Ant installed, you can just go to the directory where you unpacked the
source code bundle and start the database server using this:
ant dbstart
Launching the GUI (shown in Figure 12.1 , on the following page) is also
very easy:
ant dbgui
Finally, to shut down the server, use the following:
ant dbstop
When running the examples that use the database, make sure to start
the database server before launching the web application.
Setting Up JPA, Hibernate, and Stripersist
Now that the database is ready, the next step is to set up JPA, Hiber-
nate, and Stripersist. You'll find all the required JAR files in the lib/
hibernate and lib/stripersist directories of the sample code bundle.
Stripersist is part of the Stripes-Stuff project at http://www.stripes-stuff.org .
2.
 
 
Search WWH ::




Custom Search