Data Persistency
Representing Data permanently in Back end systems is called as “Data Persistency”. To achieve Data Persistency in database applications we will use a set of Operations [CRUD] called as Date Persistence Operations”.
To achieve Data Persistency in Enterprise Applications we will use a set of tech called as “Data Persistency Tech”.
To achieve Data Persistency in enterprise applications we will use the following technologies w.r.t JAVA.
- Serialization and Deserialization
- JDBC
- ORM Implementations
- Hibernate
- EJBs Entity Beans
- JPA
- Open JPA
- Toplink
Data Persistency through Serialization and Deserialization
The process of Separating Data from an Object is called as “Serialization”. The process of regenerating an object on the basis of Data is called as “Deserialization”.
To perform Serialization and Deserialization JAVA has provided the following two byte oriented streams
- Object OutputStream for Serialization
- Object InputStream for Deserialization
Steps to perform Serialization
- Prepare Serializable class by implementing java.io.Serializable marker interface
class Employee implements Serializable { } Employee emp1 = new Employee();
Create FileOutputStream object
FileOutputStream fos = new FileOutputStream("employee.txt");
Create ObjectOutputStream for Serialization.
ObjectOutputStream oos = new ObjectOutputStream(fos);
Write Serializable Object in ObjectOutputStream
oos.writeObject(emp1);
Steps to perform Deserialization
Create FileInputStream from Source File
FileInputStream fis = new FileInputStream("employee.txt");
Create ObjectInputStream for Deserialization
ObjectInputStream ois = new ObjectinputStream(fis);
Read Deserialized Object from ObjectInputStream
Employee emp2 = (Employee)ois.readObject();
- In Serialization and Deserialization Data Persistency mechanism, we will store data in file system, where file system is providing permanent storage for our data, so that, Serialization and Deserialization is a Data Persistency Mechanism.
- In Serialization and Deserialization data persistency mechanism, we will use a flat file to store data, it is platform dependent, it is not suitable for the platform independent front end technologies like JAVA, .NET etc
- In Serialization and Deserialization Data Persistency mechanism, we will use two byte oriented streams like ObjectOutputStream and ObjectInputStream to perform Serialization and Deserialization, so that, this data persistency mechanism is suitable for only byte oriented data.
- In this data persistency mechanism, we are using file system to store data , it able to store less data , it able to provide less security and it able to increase data redundancy, it is not suggestible in applications.
- This persistency mechanism is suitable for Standalone applications, not suitable for enterprise applications.
- If we use this data persistency mechanism in Enterprise applications then we have to provide lot of java code.
- In Serialization and Deserialization data persistency mechanism we are able to perform
- only insertion and retrieval operations, we are unable to perform update, delete etc operations.
- In this data persistency mechanism, query language support is not existed so that database operations are very much difficult.