Hibernate Tutorial

Hibernate tutorials

Hibernate, created by Gavin King, known as the best and dominated object/relational persistence (ORM) tool for Java developers (Now is support .NET). It provides many elegant and innovative ways to simplifies the relational database handling task in Java.

Hibernate is great at a lot of things, but its something that needs to be used appropriately. In this tutorials, it providing many step by step examples and explanations on using Hibernate3.

P.S Tutorials are updated to Hibernate v3.6.1.Final.

Hibernate Quick Start

Hello World example to experience the Hibernate framework.

Hibernate Association (Table Relationship)

How to define table relationship one-to-one, one-to-many, many-to-may in Hibernate.

Hibernate / JBoss Tools + Eclipse IDE

Learn how to use the Hibernate tools is a must!

Hibernate Logging

How to do logging in Hibernate

Hibernate Connection Pool

How to configure database connection pool in Hibernate

Hibernate Cascade

Hibernate cascade is use to manage the state of the other side automatically.

Hibernate Query Language (HQL)

Hibernate own language for the data manipulation, it’s quite similar to database SQL language.

Hibernate Criteria

Hibernate Criteria API is an alternative to Hibernate Query Language (HQL). It’s always a good solution in many optional search criteria.

Hibernate Native SQL

In some scenarios, Hibernate HQL or Criteria is just not enough to do what you want, here you can use the native database SQL language directly.

Hibernate Named Query

Named Query lets developers put the HQL into XML mapping file or annotation for maintainability purpose, you just do not want all your HQL syntax scatter all over the Java code. :)

Hibernate Transaction

All things related to Hibernate Transaction

Hibernate Advance Technique

Some Hibernate Advance technique, seldom use but practical skills (data filter and interceptor).

Hibernate Performance

Some tweaks will make your Hibernate run faster :)

Integrate Hibernate with Other Frameworks

Examples to integrate Hibernate with other frameworks.

Hibernate FAQ

Some frequence answer questions :

Hibernate Common Errors

Here are list of the common errors messages in Hibernate development.

Off Topic

Hibernate References

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

Leave a Reply

avatar
newest oldest most voted
Arun J
Guest
Arun J

Hi sir,I have done insert update delete using your jsf integration with spring and hibernate project but how can i search the values from database ?If am giving customerid then showing about that name and address in text box and textarea.

nagaraju
Guest
nagaraju

The content of element type “class” must match “(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|
composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-
component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-
subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)”. i am getting this error while doing this could you please explain me how to solve it

john
Guest
john

Bit late here, but all hibernate tutorials contain deprecated APIs. Lots have been changed since hibernate > 4

kasuni
Guest
kasuni

Hi sir,
I want to create a simple human resource application using hibernate framework. Are there any sample projects available on those? im new to hibernate. Any help would be highly appreciated. Thank you :)

Vishwas
Guest
Vishwas

Hi Sir could you post an example for self join(one-to-many) with create and select operation

Mahesh Parmar
Guest
Mahesh Parmar

hi sir,
i want to perform simple crud hibernate + mongoDB Any idea????

SAMIK ACHARYA
Guest
SAMIK ACHARYA

sir,
i always follows your site… and your site helps me a lot many time… but dis time I see that you used all your example project using oracle 11g … plz. tell me is it cause any problem with oracle 10g??? actually I’ve to do the following work with oracle 10g
1) Retrieve some data programmatically from .stl file(Almost a text file)
2) Then insert the retrieved data into 3 tables of oracle10g using hibernate

Charles
Guest
Charles

HIbernate Distributed transaction Example please.

Venkatareddy Polimireddy
Guest
Venkatareddy Polimireddy
HI, Please help me for below situation. I have tables like: CREATE TABLE “OTHER_ACTIVITY_DETAIL” ( “SNO” NUMBER NOT NULL ENABLE, “OA_DEVELOPER” NUMBER NOT NULL ENABLE, “OA_DATE” DATE, “OA_TYPE” VARCHAR2(2) NOT NULL ENABLE, “OA_EFFORT” NUMBER, “OA_REMARKS” VARCHAR2(200), “OA_PREDEFINE” VARCHAR2(4), “ACCOUNT_CODE” VARCHAR2(5) NOT NULL ENABLE, CONSTRAINT “OTHER_ACTIVITY_DTL_PK” PRIMARY KEY (“SNO”) ENABLE ) ** Note: OA_PREDEFINE may null in my situation. CREATE TABLE “PRE_DEFINE_ACTIVITY” ( “SNO” NUMBER NOT NULL ENABLE, “PRE_DEFINE_CODE” VARCHAR2(4) NOT NULL ENABLE, “PRE_DEFINE_DESC” VARCHAR2(50), “PRE_DEFINE_MONTH” DATE, “ACCOUNT_CODE” VARCHAR2(5) NOT NULL ENABLE, CONSTRAINT “PRE_DEFINE_ACTIVITY_PK” PRIMARY KEY (“SNO”) ENABLE ) I used in hbm like : Please help me to prepare HQL.… Read more »
????
Guest
????

Hello. I’m a Korean Student Studying Hibernate. Whenever I google Spring or Java and Hibernate. I found your blog’s Articles. Everytime. Thanks a million. Your tutorial is very helpful for me.

james
Guest
james
Dilip Yadav Mahto
Guest
Dilip Yadav Mahto

nice tutorial..its an easy to understand each steps

Amit Swain
Guest
Amit Swain

Hii folks i am getting this error while using hibernate with jpa…”java.lang.ClassNotFoundException: org.hibernate.integrator.spi.Integrator”thanx in advance

Vamshi
Guest
Vamshi

Hello, I have a scenario, where i have to fetch parent table with specific childs (not all). for example, table A has one to one relationship with table B and C.I want to fetch table A data with table B only (not C). Do we have any configuration for the same. Other approach we thought was to remove mapping and fetch A and B using left join. but looks like HQL doesn’t support left join on independent tables. can you please suggest.

Thanks in advance.

Abdulbaset
Guest
Abdulbaset

Hi Sir,

i am using session to write a bulk of entities to DB in first 3 hours i have
dumping rate around 2500 record per minute but after that the rate go down to
be 100 records per minute

Vusumzi
Guest
Vusumzi
Hi We have a web app using hibernate 3 and a sql server 2008 database. we have a table with query timeouts due to a deadlock caused users accesing the table at once when the query is called from the web app and also when I run the query in sql server it runs forever without returning data. So I ran the query in sql server with “with (no lock)” e.g “select * from Table table with(nolock) where (criteria)…” and it works perfectly….BUT when put “with (no lock)” in the query of my DAO implementation as follows: sql.append(“select count(*)”); sql.append(”… Read more »
prathmesh
Guest
prathmesh

Java ternary operator

prathmesh
Guest
prathmesh

Mostly used for Null pointer exception
eg: request.getParameter(“”)==null?1:2

gaurav
Guest
gaurav

Hi mkyoung
can u please provide tag example , it is required . please help me , thanks in advance

Cody Veit
Guest
Cody Veit

Thanks for sharing. You’ve saved me days of Googling effort.

Jay
Guest
Jay

I always read your blogs and tutorials.

Premkumar
Guest
Premkumar

is it possible to execute a sql query with the help of hibernate

Vasu
Guest
Vasu

You can execute sql queries by createSQLQuery method in hibernate

Premkumar
Guest
Premkumar

i have doubt is it possible to execute a sql query with the help of hibernate

Saood
Guest
Saood

Yes We can execute a sql query with the help of hibernate

Query query = session.createSQLQuery(“Write Query here”);
//If some parameter to be passed
query.setParameter(0,value1);
List list = query.list();

shashi kant sharma
Guest
shashi kant sharma

Superb…. Boss

Diva
Guest
Diva

you can find some more details in the below link,”http://javadomain.in/multiple-databases-using-hibernate-example/”

Venkat
Guest
Venkat

Hi , BuildSessionFactory also deprecated , so i think its better explain about it also..Thank you

anji
Guest
anji

how to set the default values in SimpleFormController in spring mvc?

anji
Guest
anji

how to resolve org.hibernate.LazyInitialiazationException?

trackback
hibernate ?? | demonstrate ? blog

[…] ? ORM ????????????????? maven ? build tool?model ?? mkyong ? […]

Balu
Guest
Balu

hello sir your java/j2ee concepts r really useful & powerful.thanq very much sir

Rahul
Guest
Rahul

Hi MK,

Great tutorials always ! I am waiting for hibernate annoatation configuration with entity manager configuration tutorials. I am having some issues in the entity manager configuration.

:)

Thanks !
Rahul