Hibernate, created by Gavin King, known as the the best object/relational persistence tool for Java developers (Now is support .NET). It provides many elegant and innovative ways to simplifies the database transaction handling 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 Hibernate 3.0.
Happy learning Hibernate.
Hibernate Quick Start
Let’s go through a quick guide to understand the Hibernate.
-
Maven + Hibernate XML Mapping + MySQL Example
A quick start to create a project with Maven, Hibernate (XML mapping file) and MySQL. -
Maven + Hibernate Annotation + MySQL Example
A quick start to create a project with Maven, Hibernate (Annotation) and MySQL.
Hibernate Configuration
All stuff of Hibernate configuration, XML mapping file, connection pool, logging and Hibernate dialect .
-
How to load hibernate.cfg.xml from different directory
By default, Hibernate looking the hibernate.cfg.xml at the project class path, here’s a guide to load it from specified folder. -
How to add Hibernate XML mapping file (hbm.xml)
programmatically
A tip to load hibernate.cfg.xml programmatically -
How to configure the C3P0 connection pool in Hibernate
The connection pool is used to increase the system performance by avoid the hit to database too often. The C3PO id the default Hibernate connection pool, here’s a guide to configuration it. -
Hibernate Dialect Collection
A list of the dialect collection for different type of database vendors. -
How to configure Log4j in Hibernate project
Log4j is a popular logging tool, here’s a guide to integrate Log4j in Hibernate project. -
show_sql , format_sql and use_sql_comments
Configure Hibernate to display the generated SQL statement to console.
Hibernate Association (Relationship)
How to define the table relationship in Hibernate, including some useful relationship tweaks like inverse usage.
-
One-to-one relationship example
A one-to-one relationship project demonstration. -
One-to-many relationship example
A one-to-many relationship project demonstration. -
Many-to-many relationship example
A many-to-many relationship project demonstration. -
inverse = “true” example and explanation
The “inverse” is the most confusing keyword in Hibernate, but you have to understand this clearly in order to fine tune your relationship performance.
Hibernate Cascade
Hibernate cascade is use to manage the state of the other side automatically.
-
Cascade example (save, update, delete and
delete-orphan)
Cascade examples in save, update, delete and delete orphan. And the different between delete and delete orphan. -
Different between cascade and inverse
Many Hibernate developers are confuse about the different between the cascade and inverse, here’s the explanation. -
Cascade – JPA & Hibernate annotation common mistake
A super easy common annotation mistake made by beginner or experienced Hibernate developers – JPA cascade annotation in Hibernate?
Hibernate Query Language (HQL)
Hibernate own language for the data manipulation, it’s quite similar to database SQL language.
-
Hibernate Query examples (HQL)
HQL CRUD examples , select, update , delete and batch insert (no single insert support). -
Hibernate parameter binding examples
Bind the parameter into HQL with “Named parameters” and “Positional parameters” methods. -
How to embed Oracle hints in Hibernate query
A trick to embed the Oracle hints into Hibernate Query to increase the Oracle query performance.
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 Criteria examples
Criteria examples – basic query, ordering query, restrictions query and paging the result.
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 native SQL queries examples
A guide to show how to use native SQL in Hibernate.
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 named query examples
Working with named query in XML file and Annotation.
Hibernate Transaction
All things related to Hibernate Transaction
-
Hibernate Transaction handle example
A simple standard example to use Hibernate transaction.
Hibernate Advance Technique
Some Hibernate Advance technique, seldom use but practical skills (data filter and interceptor).
-
Hibernate data filter example – XML and annotation
Hibernate data filter is used to filter the retrieve data from database, Here’s a guide to work with data filter in XML or Annotation. -
Hibernate interceptor example – audit log
Hibernate interceptor is used to intercept the Hibernate events like CRUD operations, a detail example of audit log implementation with Hibernate interceptor.
Hibernate Performance
Some tweaks will make your Hibernate run faster
-
dynamic-insert attribute example
Using dynamic-insert to avoid the include unmodified properties in the SQL INSERT statement. -
dynamic-update attribute example
Using dynamic-insert to avoid the include unmodified properties in the SQL UPDATE statement. -
Hibernate mutable example (class and collection)
Using mutable keyword to avoid the generate unnecessary SQL statements. -
Hibernate – fetching strategies examples
Hibernate fetching strategies are used to optimize the Hibernate generated select statement, a must learn skill for any Hibernate developers. -
Different between session.get() and session.load()
Understanding when should use get or load to retrieve the object in order to avoid unnecessary hit to the database.
Integrate Hibernate with Other Frameworks
Examples to integrate Hibernate with other frameworks.
-
Struts + Hibernate Integration
Example to integrate Hibernate with Struts framework. -
Struts + Spring + Hibernate Integration
Example to integrate Hibernate with Struts and Spring framework together. -
Spring + Hibernate Integration
Example to integrate Hibernate with Spring framework. -
Spring + Hibernate Integration (Annotation)
Example to integrate Hibernate with Spring framework (Annotation version).
Hibernate Tips & Tricks
-
How to display hibernate sql parameter values – P6Spy
Using P6Sqpy third party library to display the Hibernate SQL parameter value. -
How to display hibernate sql parameter values – Log4j
Using Log4j to display the Hibernate SQL parameter value. -
How to call store procedure in Hibernate
It’s not recommend to put business logic into store procedure, never mind, you still allow to call store procedure in Hibernate. -
How to use database reserved keyword in Hibernate
In some special case, you may need to use the database keyword in your Hibernate class (not recommend), here’s a trick to achieve it. -
How to save an image into database
A tutorial to show how to use Hibernate to save an image into database.
Hibernate Tools
Hibernate tools is a very handy tool to generate the Hibernate code automatically. Working with Hibernate API or mapping metadata are tedious always, this tool will save you much of time, and it’s also a very Hibernate learning platform by studying the generated code.
Hibernate Common Errors
Here’s are list of the Hibernate common errors messages.
- Remember that ordinal parameters are 1-based! – Hibernate Template
- org.hibernate.AnnotationException: Unknown Id.generator
- An AnnotationConfiguration instance is required to use
- java.lang.NoClassDefFoundError: org/dom4j/DocumentException
- java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
- java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
- java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
- java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/DataSources
- java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
- java.lang.NoClassDefFoundError: antlr/ANTLRException
- java.lang.NoClassDefFoundError: javax/transaction/Synchronization
- java.lang.ClassFormatError : Absent Code attribute in method that is not native or abstract in class file …
- java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter
- java.lang.ClassNotFoundException: javax.persistence.Entity
- java.lang.ClassNotFoundException: javax.transaction.TransactionManager
- java.lang.ClassFormatError : Absent Code attribute in method that is not native or abstract in class file …
Hibernate Misc
- Why i choose Hibernate for my project?
The reasons why i like to implement Hibernate in the future project.
home
Info
sitemap




