Fetching strategies in Hibernate

Hibernate uses a fetching strategy to retrieve associated objects if the application needs to navigate the association. Fetch strategies can be declared in the O/R mapping metadata, or over-ridden by a particular HQL or Criteria query. Hibernate3 defines the following fetching strategies: Join fetching: Hibernate retrieves the associated instance or…

Continue reading

Joins In Hibernate

Hibernate supports 4 types of joins.. Left Join Right  Join Full Join Inner Join the DEFAULT join in hibernate is Inner join Similar posts: Hibernate Architecture Hibernate Using Mapping File Inheritance Mapping In Hibernate Inheritance-Table Per Class Hierarchy Hibernate-generator-element

Continue reading

Hibernate Caching

In hibernate every new session has its own cache memory, Caching is a mechanism for storing the loaded objects into a cache memory. The advantage of cache mechanism is it give high performance, whenever again we want to load the same object from the database then instead of hitting the…

Continue reading

Hibernate Batch Processing

Suppose we have a requirement where we have to insert 1000000 records in to database in a time. How to do this ? Using  Native Solution : Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<1000000; i++ ) { Student student = new Student(…..); session.save(student); } tx.commit(); session.close();…

Continue reading

Calling stored procedure in Hibernate

First create a MySQL store procedure Here’s a MySQL store procedure, which accept a stock code parameter and return the related stock data.

In MySQL, you can simple call it with a call keyword :

Hibernate call store procedure In Hibernate, there are three approaches to call a…

Continue reading

Executing HQL Commands

We can execute our HQL command in 3 ways, like by selecting total object, partial object (more than one column), partial object (with single column). By Selecting Complete Object : This approach, complete object is selected from the database, so while iterating the collection, we need to typecast each object…

Continue reading

Introduction to Hibernate Query Language

In hibernate we can perform the operations on a single row as well as multiple rows at a time, when we do operations on multiple rows at once, then we can call this as bulk operations. HQL is the own query language of hibernate and it is used to perform…

Continue reading

Hibernate-generator-element

Understanding Hibernate <generator> element In hibernate generator classes are used to generate unique identifiers for instances of the persistence class. Hibernate provides the list of built in generator classes to generate unique identifiers, all the generator classes implements the org.hibernate.id.IdentifierGenerator interface, and if your needs of unique identifiers is not…

Continue reading

Composite Primary Keys In Hibernate

Composite primary keys means having more than one primary key. Now lets see what does Composite primary keys means in Hibernate If the table has a primary key then in Entity class we configure that column using @Id annotation and in the hibernate mapping file we need to configure that column by using <id />…

Continue reading