Eclipse Web Tools Platform: Developing Java Web Applications by Naci Dai, Lawrence Mandel, Arthur Ryman
Purchase From
more options...
  • Amazon.com
  • Barnes & Noble
  • Chapters/Indigo
  • Safari Books Online

Chapter 9 - The Persistence Tier

-Salvador Dali,
About The Persistence of Memory

I paint to systematize confusion and thus to help discredit completely the world of reality.

Java objects live in computer memory and normally vanish when the program that created them terminates. The lifecycle of most objects ends then. However, some objects must survive for a longer period of time. Databases and files are common datastores that you can use to keep these objects around for extended periods of time. The application layer that deals with mapping objects from memory to datastores is called the persistence layer, and the place where these objects are stored is called the persistence tier (see the Persistence section in Chapter 5).

The simplest type of persistence in Java is serialization, which supports writing and reading objects using streams. Java serialization is used to temporarily store inactive stateful session beans on disk when memory gets full. Java serialization is also used in Remote Method Invocation (RMI), which EJBs use for object distribution. When a remote EJB is called, the Java objects in the parameter list are serialized into a stream and sent over the network where they are deserialized by the receiving object. However, Java serialization is not a good approach for long-term persistence since it can only be used in practice by other Java applications. Programming-language-neutral file formats and databases are better alternatives.

Modern applications have many options to store data, but it is probably safe to say that most Web applications use relational databases to persist objects.

Let's start with restating some of the more important principles for building a data layer.

...

This is only a preview.
Read more sample content | Purchase Eclipse Web Tools Platform

Other Sections in This Chapter

  • Designs for the Persistence Layer
    • Use JDBC APIs to Map Objects to a Database
    • Use Entity Beans to Map Objects to a Database
    • Use Object-Relational Frameworks to Map Objects to a Database
  • Overview of Iterations
  • Iteration 1: Creating a Database
    • Summary of Iteration 1
  • Iteration 2: Data Layer
    • Summary of Iteration 2
  • Iteration 3: Entity Beans
    • Preparing JBoss, Derby, and XDoclet
    • Adding a CMP
    • Adding ejbCreate and finder Methods
    • Adding the Ice Hockey CMP Data Access Object
    • Testing the CMP Implementation
    • Developing JPA with WTP
    • Summary of Iteration 3
  • Summary