Before we dive into “Java Persistence” in complete elaboration, let’s first understand what the word Persistence means.
What is Persistence?
Persistence in computer programming means to store (persist) the state of a program so that it can be retrieved at any point of time, independent of the process which persisted it.
WikiPedia has the definition of Persistence as “persistence refers to the characteristic of state that outlives the process that created it. This is achieved in practice by storing the state as data in computer data storage”.
Suppose you are playing a game which has got multiple levels, let’s say 10. You started playing and continued with it until you get tired at Level 7. You want to take some rest. You go to the options and save the game.
Now, for some reason your playstation (or XBOX) got switched off. Will you be able to resume the game from Level 7 or you will have to start from Level 1? Ofcourse, it will resume from Level 7.
Your gaming software(persisting process) persisted the state of the game in the underlying database and re-instantiated the game after it got started.
Now, when you have understood what persistent means. It’s time to dive into what persistence means in the context of Java.
What is Java Persistence?
As you know, Java is an Object Oriented Programming Language. Everything including the state of a Java Program is in and through objects. You can call a Java application as different collection of objects interacting with each other.
Above image shows a Sample object graph representing the state of ‘University Software’. So, what should be the meaning of persisting the state of ‘University Software’ : Storing the sample object graph into some underlying mechanism (maybe MySQL Database), which is detached from ‘University Software’.
So, in the context of Java, persistence means to store the object graph of the Java application.
Hence, Java Persistence is the technique to store Java Objects into some underlying storage mechanism/technology which is detached from Java application itself.
Java Persistence in Layered Archiecture
Below image gives the typical layered architecture of a software application. Here, Persistence is done at Persistence Layer (also called DAO layer in Java community).
Persistence Layer abstracts the business layer from underlying storage system.
List of different Java Persistence Technologies
Java provides different persistent technologies to deal with different software problems related to persistence.
- Java DataBase Connectivity (JDBC)
- Java Persistence API (JPA)
- Java Data Objects (JDO)
- Java Connector API (JCA)
- Service Data Objects (SDO)
- Enterprise Java Beans (EJB) – Entity Beans
List of different Java Persistence Frameworks
Based on (implementation of) one or more of the Java Persistence technologies above, there are a number of Java persistence frameworks available in the market:
- Apache Cayenne
- Apache Gora
- Athena Framework
- DataNucleus(formerly known as JPOX)
- Enterprise JavaBeans (EJB)
- Enterprise Objects Framework part of Apple WebObjects
- Fast Java Object Relation Mapping (Fjorm)
- Java Data Objects (JDO)
- Java Object Oriented Querying (jOOQ)
- MyBatis (formerly named iBATIS)
- QuickDB ORM
Waiting your comment, questions, suggestions in the comment section below.