Posts

Showing posts with the label hibernate auto increment with example

Hibernate auto increment with example

In previous example we learn how to map java object with database table for manually(not using auto increment) assigned all the values.  To create primary key auto increment application by using hibernate mapping(hbm.xml) or using annotations continue reading this article.  W e need to create a database and create an employee table by using the below query. Table: CREATE table EMPLOYEE( eid integer ( 10 ) primary key not null , firstname varchar ( 30 ), lastname varchar ( 30 ), designation varchar ( 30 ), salary double( 10 , 2 )); Here, we will create a bean/POJO (Plain Old Java Object) class of employee. Employee.java: package com . javatbrains . hibernate ; import java.io.Serializable ; /*This is the POJO class. It contains only Getter and Setter methods*/ public class Employee implements Serializable { private static final long serialVersionUID = - 75885815725314443L ; private int eid ; private String firstName ;