Learn courses for free
Publish new courses and earn
Check your skills
Improve your skillsets for free
 
or
    
learnNpublish - Quick Learning Management System
Java Hibernate Tutorial Part 5 [ Share ,Read]
Java Hibernate Tutorial
One to One Bi-directional
One to Many Mapping
Many to Many Mapping
Rating:     Type:Free     Points Required: 0
Java Hibernate Tutorial Part 4 [ Share ,Read]
Java Hibernate Tutorial
Compound Primary Key
Inheritance Mapping
One to One Mapping
Rating:     Type:Free     Points Required: 0
Java Hibernate Tutorial Part 3 [ Share ,Read]
Java Hibernate Tutorial
more annotations
Auto Generate Primary key
One class to Two tables
Two classes to One table
Rating:     Type:Free     Points Required: 0
Java Hibernate Tutorial Part 2 [ Share ,Read]
Java Hibernate Tutorial

Create table from Class
Schema Change
Insert record (object)
Review

Java Persistance

When we write Java code, we create objects, and those objects have properties. Here's a simple piece of code. Just by looking at it, I think you can tell what the User's name and password are:

User user = new User();        //an object named user is created
user.setName("Cameron");       //name is initialized to Cameron
user.setPassword("n0tte11ing");//password is initialized to n0tte11ing

I think even the uninitiated Java programmer would recognize that we have just created a user named Cameron with a password of n0tte11ing. We see this type of object creation and property initialization in Java programs all the time. But the problem Java developers always have is figuring out how to take the data associated with the object and save it to the database. Hibernate makes the persistence of your Java objects, aka Java Persistence, easy.

Just how easy is it to persist Java objects with Hibernate?

With a magical and mystical object known as the Hibernate Session, persisting the state of your Java objects is easy. Look how readable and understandable the following code is:

User user = new User();        //an object named user is created
user.setName("Cameron");       //name is initialized to Cameron
user.setPassword("n0tte11ing");//password is initialized to n0tte11ing
Session hibernateSession = HibernateUtil.getSession(); 
                               //get the magical Hibernate session
hibernateSession.save(user);   //save the user to the database!

The line of code hibernateSession.save(user); saves the state of the user instance to the database. Of course, there's a little bit of plumbing code that needs to go in there to make the whole hibernate framework work; But setting up that plumbing code really isn't that bad. Overall, Hibernate is real easy to use, fairly easy to set up, and probably the easiest way to manage the persistent state of you domain model objects.


Rating:     Type:Free     Points Required: 0
Java Hibernate Tutorial Part 1 [ Share ,Read]
Java Hibernate Tutorial

                                                   Hibernate is an ORM tool. Hibernate is a solution for object-relational mapping and a persistence management layer. For example a java application is used to save data of an object to a database. Hibernate provides a solution for this persistence by mapping database tables to a class. The database data is copied to the object. The copying the data as objects and vice versa is known as object-relational mapping. A query that uses select statement and its operations of fetching tuples is done by a simple query object. And being an object, the same object can be utilized several times, which reduces the ‘query defining time’. Usage of simple java classes [ Plain Old Java Objects ] makes this task simple instead of using entity beans / JDBC calls.
  • Hibernate is a powerful, high performance object/relational persistence and query service.
  • Hibernate allows development of persistent classes following object-oriented idiom that includes association, inheritance, polymorphism, composition, and collections.
  • Hibernate allows expressing queries in its own portable SQL extension (HQL), as well as in native SQL, or with an object-oriented Criteria and Example API.
setup
install hibernate
customise
Our First Class!
Rating:     Type:Free     Points Required: 0