12:26 am - Monday May 1, 2017

Archive: Z-A Hibernate codes Subscribe to Z-A Hibernate codes

Hibernate Inheritance mapping table per concrete class inserting Data Using Eclipse

Project Structure:                       JAR FILES:                       Book.java: package com.candidjava; import java.io.*; import java.util.*; public class Book { int id; String title; String author; double...

Hibernate Inheritance mapping table per class Fetching data Using Eclipse

Project Structure:                   JAR FILES:                       Book.java: package com.candidjava; import java.io.*; import java.util.*; public class Book { int id; String title; String author; double...

Hibernate Inheritance mapping table per class inserting Data Using Eclipse

ProjectStructure:                    JarFiles:                        Book.java: package com.candidjava; import java.io.*; import java.util.*; public class Book { int id; String title; String author; double...

Hibernate Collection mapping Map Using Eclipse

Project Structure:                 JAR Files:                     MainClass.java: package com.candidjava; import java.io.DataInputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import...

Hibernate Collection mapping bag Using Eclipse

Bag: Bag allows duplicates. <bag name=”studentPhoneNumbers” table=”SPHONE_om” cascade=”all”> <key column=”SID” /> <many-to-many column=”PID” unique=”true”...

Hibernate Collection mapping Set Using Eclipse

Set:  Set doesn’t contain duplicates. <set name=”anyName” table=”tableName” cascade=”all”> <key column=”uniqueIdColumnName” /> <many-to-many column=”columnName”...

Hibernate collection mapping List Using Eclipse

List: List can contain duplicates. <list name=”listName” table=”tableName” cascade=”all”> <key column=”anyColumnName”></key> <list-index column=”anyColumnName”> ...

Hibernate component mapping Fetching Data Using Eclipse

ProjectStructure:                     JarFiles:                           Address.java: package com.candidjava; public class Address implements java.io.Serializable { private long addressId; private String...

Hibernate component mapping Inserting Data In Eclipse

Component: Component mapping save details in a single table. This is used to get input from more than one page and save all details in a same table. Here two pojo classes are used (Address,Student). Get inputs from these two pojo classes...

Hibernate CreateCriteria OrderbyDesc in Eclipse

•  This explains how to fetch data’s in descending order. •  createQuery(“from Student stu where stu.id > 2 ORDER BY stu.stuid DESC”); •  DESC – implies descending order. Project Structure:                        JarFiles:      ...

Hibernate CreateQuery OrderbyAsc in Eclipse

•  This explains how to fetch data’s in ascending order. •  createQuery(“from Student stu where stu.id > 2 ORDER BY stu.stuid ASC”); •  ASC – implies ascending order. Project Structure:                       Jar...

Hibernate Pagination CreateQuery Using Eclipse

•  Pagination – Retrieve specified number of rows in a table. •  This is using createQuery. •  For ex Query: o  Query query = s.createQuery(“from Student stu where stu.degree = :deg order by stu.id desc”); o  query.setString(“deg”,”BE”); o...

Hibernate Pagination CreateCriteria Using Eclipse

•  Pagination – Retrieve specified number of rows in a table. •  This is using createCriteria. •  For ex Query: o  Criteria c=s.createCriteria(Student.class).add(Restrictions.like(“degree”, “BE”)) o  c.setFirstResult(0); o...

Hibernate Association Mapping Using One-To-One to Fetching Data

Project Structure:                         JAR Files:                     Address.java: package com.candidjava; public class Address implements java.io.Serializable { private long addressId; private String...

Hibernate Association Mapping Using One-To-One to Inserting Data

Project Structure:                         JAR Files:                       CREATE THE FOLLOWING JAVA FILES AND POJO CLASS FILES:         Address.java: package com.candidjava; public class Address implements...

Hibernate Association Mapping Using One-To-Many to Fetching Data

Project Structure:                       JAR Files:                     MainClass.java: package com.candidjava; import java.util.*; import java.io.*; import org.hibernate.*; import org.hibernate.cfg.*; import...

Hibernate Association Mapping Using One-To-Many to Inserting Data

Project Structure:                       JAR Files:                     MainClass.java: package com.candidjava; import java.io.DataInputStream; import java.util.HashSet; import java.util.Set; import org.hibernate.*; import...

Hibernate Association Mapping Using Many-To-One to Fetching Data

Project Structure:                         JAR Files:                     Address.java: package com.candidjava; public class Address implements java.io.Serializable { private long addressId; private String...

Hibernate Association Mapping Using Many-To-One to Inserting Data

Project Structure:                       JAR Files:       Address.java: package com.candidjava; public class Address implements java.io.Serializable { private long addressId; private String street; private String...

Hibernate Association Mapping Using Many-To-Many to Fetching Data

Project Structure:                             JAR Files:                     Course.java: package com.candidjava; /** * This class contains the course details. * */ public class Course implements java.io.Serializable...