Java Persistence/What is Java persistence?

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Persistence, in computer science, is a noun describing data that outlives the process that created it. Java persistence could be defined as storing anything to any level of persistence using the Java programming language, but obviously this would be too broad a definition to cover in a single book. That is why this book is more focused on storing Java objects to relational databases. In particular using the Java Persistence API (JPA).

There are many ways to make data persist in Java, including (to name a few): JDBC, serialization, file IO, JCA, object databases, and XML databases. However, the majority of data is persisted in databases, specifically relational databases. Most things that you do on a computer or web site that involve storing data, involve accessing a relational database. Relational databases are the standard mode of persistent storage for most industries, from banking to manufacturing.

There are many things that can be stored in databases with Java. Java data includes strings, numbers, date and byte arrays, images, XML, and Java objects. Many Java applications use Java objects to model their application data. Because Java is an Object Oriented language, storing Java objects is a natural and common approach to persisting data from Java.

There are many ways to access a relational database from Java, JPA is just the latest of many different specifications, but it seems to be the direction that most programmers are heading.