I was reading out the basics of ORM from here where it is defined what is persistence?
here it is defined as
we would like the state of (some of) our objects to live beyond the scope of the JVM so that the same state is available later.
I could not understated what does it mean by beyond the scope of the JVM . what i have understood form this could be
Please correct me because truly speaking I did not understand this statement which is defined in Hibernates own official site.
beyond the scope of the JVM
means that the state will still exist even after the JVM shuts down. Or, to put it another way, the existence of the state is not dependent on the existence of the JVM. Hibernate is an ORM (object relational mapping) tool which is typically used to map Java objects to records in a database somewhere. When used this way, Hibernate stores state from your Java program in one or more database tables.
Consider the following definition for the Person
class:
public class Person {
private String firstName;
private String lastName;
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
// getters and setters
}
Suppose you create 2 Person
objects like this:
Person p1 = new Person("Jon", "Skeet");
Person p2 = new Person("Gordon", "Linoff");
If you were to persist these Person
objects to the database using Hibernate, you might end up with a Person
table looking like this:
+-----------+----------+
| firstName | lastName |
+-----------+----------+
| Jon | Skeet |
| Gordon | Linoff |
+-----------+----------+
If you stop your Java application and then start it up again, Hibernate can also work in the opposite direction to create Person
objects from the rows in this database table.
Persistence means to save data in place that would remain or persist even after the power is turned off. For example saving data in text files is also persistence. Database is one of the ways of persisting data .
You know this, its just a big word.
Beyond the scope of JVM means the data should persist or be preserved even after JVM shuts down i.e your application shuts down.
Hibernate saves or persists a Java bean/object in database. So it is called ORM Object to Relational Mapping framework. This is simple they just use a lot of fancy words so it sounds cool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With