Is it possible to map two classes to the same table? For example:
I have a table EMPLOYEE with columns: id, name, address1, address2, city, state, employername, employeraddress, salary
What I did was: I made two mapping files: employee.hbm.xml and address.hbm.xml.
employee.hbm.xml maps to EMPLOYEE table with id, name, employername, employeraddress, salary (class name: Employee)
address.hbm.xml maps to EMPLOYEE table with id, address1, address2, city, state (class name: Address)
and employee.hbm.xml has one-to-one reference to Address class.
Please let me know if the concept is technically correct. I was getting a Null Pointer exception while query ( 'select e from Employee e') ( I do not have the exact error right away because I changed my design to avoid this situation)
Null Pointer Exc
org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1645)
Please help me understand what wrong I am doing.
Thanks
|