I am creating a basic hibernate application for employee table in which I am adding, updating, deleting and displaying the record with the help of ManageEmployee class.
Actually, ManageEmployee is my
test class and i am using Employee.java and Employee.hbm.xml file to do above things.
Details: Database: Oracle 11 g Hibernate version: hibernate-release-4.3.8.Final
Java Version: Java 1.8
Employee Table Details:
USER_ID NUMBER(15,0) No 1 1
FIRST_NAME VARCHAR2(20 BYTE) Yes 2
LAST_NAME VARCHAR2(20 BYTE) Yes 3
SALARY NUMBER(10,0) Yes 4
Error Log: you can see in the log that error is coming 3 times because I am adding Employee object 3 times in ManageEmployee.java class with addEmployee(...) method so I am assuming that problem is with the sequence generator for the column id.
Here I am using naive generator. i.g. Integer empID1 = ME.addEmployee("Zara", "Ali", 1000);
ManageEmployee.java file Code:
Mapping File: