Object persistence means storing the object state in data store and re-create at later point of time. Let's
understand the object persistence
with an example. Let's say that you are working on java application and one of the class in an application
is Book
class which has some of member variables and some methods as well. Now you have created an
object of this class in an application and state of the newly created book object is in java virtual machine.
Question: Let me ask you a question what do you think will happen when Java Virtual Machine on that your application is running, is stopped.
Answer: You will lose the state of all the object created in an application that was in heap memory.
Solution: You need to store the data of all the objects of an application to the data store, so even if the JVM is not running you will not lose the state of the objects. Whenever you bring the application up the same state of objects will come back to your application that you had stored in the data store.
You have a book object state in heap memory, Once you store the state of this object to data store then data of book object will live beyond the scope of java virtual machine.
whenever we talk about object persistence or persistence of object what it means that the state of an object can be saved to a data store and recreate it later point in time. Now there are many ways to make data persistence in Java. You could persist this data to file or a relational database and there are many ways as well. In this course, we will be persisting java object into a relational database.
No comments :
Post a Comment