When I try to run it, it insert record in Emp table only. On adding cascade="all" in one-to-one mapping of emp.hbm.xml file, an exception is thrown 'attempted to assign id from null one-to-one property: emp'.
the mapping for Emp says : you are making use of increment generator for assigning ids.
But in your java code, you are assigning empNo in the Salary.id. With such type of mapping you are only suppose to do mapping. Hibernate will take care of populating the value in the Emp_Salary.empno column from the primary key of Emp table.
So comment the line of code where you are assigning the empNo in the Salary object. It should work.
Naresh Waswani +91-9986461501
posted 12 years ago
I commented that line, but still its not working. Only inserting record in Emp table.