Hibernate Tutorials – Hibernate Join, Mappings et al


Have you been looking for tutorials to understand Hibernate better?? Is there a project deadline coming up and you are nowhere close to completing even the Data Access Layer?

Ok, Here are some tutorials for understanding Hibernate. But there is one thing you must understand – Using Hibernate alone and using Hibernate with JPA are two different things. I realised this after reading these tutorials. Hibernate can be used in two ways –
1. As a means to connect to database, and also as a means to fetch data from there. You will use
import org.hibernate.Configuration;
import org.hibernate.Session; for the initial settings and
import org.hibernate.Query; to create the queries for the data.

If you dont use these in your files, then you are NOT using hibernate to fetch the data.

2. The other way of using Hibernate is to use it in combination with JPA, Java Persistence API. Hibernate connects to the database, and maps to objects, and JPA is used as a means to fetch data. This will mean you will write your queries in JPQL and not HQL. What is the difference between the two? It seems to be subtle, I will write about it when I actually find it.

Remember if you use the following

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

then you are using JPA. And these tutorials are for Pure Hibernate – Type I discussed here.

Without further ado, here is the link for pure Hibernate implementation –

Each of these are PDF files, and have been written in simple english language

http://www.metaarchit.com/articles.html

If you want to understand JPA, JPQL, and how Java Persistence API is used in a typical example, you must read these two links – these are awesome examples –

http://www.oracle.com/technology/pub/articles/vasiliev-jpql.html

http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#OneToMany

You cannot copy paste ideas from these examples, you will have to understand the concept and apply it relevantly to your application.

Advertisements

About vatsalad

Hi, I'm Vatsala
This entry was posted in hibernate and tagged , , , , . Bookmark the permalink.