In this post under Hibernate, I will explain how to create a unidirectional many to many association between objects using a mapping file with an example. For our example, we will create the below two tables. Data Definition Language CREATE TABLE `doctor1` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) NOT NULL DEFAULT ‘0’, `description`…… Continue reading Unidirectional Many to Many association mapping (without annotations)
Category: ORM
Bidirectional One to One association mapping (without annotations)
In this post under Hibernate, I will explain how to create a bidirectional one to one association between objects using a mapping file with an example. For our example, we will create the below two tables. Data Definition Language CREATE TABLE `ticket2` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `number` VARCHAR(50) NOT NULL, `description` VARCHAR(100) NOT…… Continue reading Bidirectional One to One association mapping (without annotations)
Unidirectional One to One association mapping (without annotations)
In this post under Hibernate, I will explain how to create a unidirectional one to one association between objects using a mapping file with an example. For our example, we will create the below two tables. Data Definition Language CREATE TABLE `ticket1` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `number` VARCHAR(50) NOT NULL, `description` VARCHAR(100) NOT…… Continue reading Unidirectional One to One association mapping (without annotations)
Bidirectional One to Many association mapping (without annotations)
In this post under Hibernate, I will explain how to create a bidirectional one to many association between objects using a mapping file with an example. For our example, we will create the below two tables. Data Definition Language CREATE TABLE `series2` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) NOT NULL, `description` VARCHAR(100) NOT…… Continue reading Bidirectional One to Many association mapping (without annotations)
Unidirectional One to Many association mapping (without annotations)
In this post under Hibernate, I will explain how to create a unidirectional one to many association between objects using a mapping file with an example. For our example, we will create the below two tables. Data Definition Language CREATE TABLE `series1` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) NOT NULL, `description` VARCHAR(100) NOT…… Continue reading Unidirectional One to Many association mapping (without annotations)
Deleting a persisted object
In this post under hibrenate, I will explain how to delete a persisted object. We can delete a persisted object using Session interface delete method. Below is the complete code Main Class 1 import org.hibernate.Session; 2 import org.hibernate.SessionFactory; 3 4 public class HibernateDemo9 { 5 public static void main(String[] args) { 6 SessionFactory sessionFactory =…… Continue reading Deleting a persisted object
Session’s load vs get method
In this post under hibernate, I will introduce you to Session’s load and get method and explain their difference. Similarity 1) Both methods are used to load persistent object from the database 2) Both needs primary key id as a parameter Difference 1) If the persistent object identified by primary key is not there, then…… Continue reading Session’s load vs get method
Loading a Persistent Object
In this post under hibernate, I will explain how to load a persistent object from the database. We load a persistent object using Session interface “load” method. Several overloadded version of the “load” method exists, all these methods require the primary key id of the object to be loaded. Below is the complete code Main…… Continue reading Loading a Persistent Object
Saving a transient object
In this post of Hibernate ORM, I will explain how to save a transient object with an example. A transient object exists only in memory, no representation of it exists in database. Hibernate runtime doesn’t manage (ie., automatically update or sync up with database representation) the transient object. The object’s identifier property value will be…… Continue reading Saving a transient object
Saving entities in a batch
This post explains how to save large number of entities in one batch or one unit of work. First we need to set the below property in configuration file hibernate.jdbc.batch_size The value will be an integer, which indicates the number of insert statements to be grouped together as one unit of work or one batch.…… Continue reading Saving entities in a batch