Hibernate collections mappings

Collection is a group of objects. As hibernate maps the entity classes to the database tables so if an entity has a collection of values for a property then these types of properties can be mapped to the any one of the available java collection interfaces. Hibernate provides the facility to persist the instance of … Read more

Hibernate annotation example

As we discussed a simple hibernate program to save a student class object into the database using annotations. Let us do the same exercise with the annotations. Example: Student.java package com.w3schools.business   import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table;   /** * This class represents a persistent class for Student. * @author … Read more

Hibernate example using xml mapping

As we discussed primary things like hibernate architecture, object states, configuration files, mapping files, transaction management to make a hibernate program. Let us start with a simple hibernate program to save a student class object into the database. Example: Student.java /** * This class represents a persistent class for Student. * @author w3schools */ public … Read more

Hibernate mapping file

Hibernate mapping file is used by hibernate framework to get the information about the mapping of a POJO class and a database table. It mainly contains the following mapping information: Mapping information of a POJO class name to a database table name. Mapping information of POJO class properties to database table columns. Elements of the … Read more

Object states in Hibernate

A persistent class object can be in one of the following three states: Transient. Persistent. Detached. 1. Transient: A persistent class object is said to be in transient state if it is not associated with hibernate session. 2. Persistent: A persistent class object is said to be in transient state if it is associated with … Read more

Persistent class

Persistent classes are those java classes whose objects have to be stored in the database tables. They should follow some simple rules of Plain Old Java Object programming model (POJO). Some rules that should be, not must be followed by a persistence class. A persistence class should have a default constructor. A persistence class should … Read more

Hibernate configuration file

As we discussed that hibernate works as an intermediate layer between java application and relational database. So hibernate needs some configuration setting related to the database and other parameters like mapping files. A hibernate configuration file contains all such information. A hibernate configuration file mainly contains three types of information: Connection Properties related to the … Read more

Hibernate architecture

Hibernate architecture consist of hibernate core components and use existing Java APIs. It uses JDBC API for common functionality to communicate with relational database and JNDI and JTA to integrate hibernate to the java application servers. Diagram: Core Components of Hibernate architecture: Configuration object: The configuration object consist the configuration file used by the hibernate. … Read more

Hibernate framework

Hibernate framework is an object-relational mapping library for the Java language. It is an open source persistent framework started by Gavin King in 2001. It provides the facility to map the java classes to relational database tables and Java data types to SQL data types. Note: Hibernate framework acts as an intermediate layer between java … Read more