Hibernate version:
2.1.6
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:Oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
I have a situation like where every record to the table should first go into a audit table where it is moved into main table only after authorization by user other than who inserted/modified it. so, there are eventually two tables with same structure.
eg: Table-1: EMP_MAIN
EID
ENAME
SAL
MAKER_ID
MAKE_DATE_TIME
CHECKER_ID
CHK_DATE_TIME
Table-2: EMP_LOG
EID
ENAME
SAL
MAKER_ID
MAKE_DATE_TIME
CHECKER_ID
CHK_DATE_TIME
During insert, a record will be inserted into log table (EMP_LOG) along with maker_id and make_date_time. checker_id and chk_date_time are null. so, in this case, my mapping is between EMP_LOG and empClass. When authorization is done by other user, checker_id and chk_date_time will be updated in EMP_LOG and then the same record will be moved to EMP_MAIN table. modify and deletion also occurs in the same fashion. All the transaction are done initally in the log table and then moved to main table after authorization.
As the structures of both the tables are same I wanted to make use of same class to map both the tables. remember that initally I want to insert into log table alone. and only on auth, it should be moved to main table. Please provide the mapping or coding solution to achieve insert and auth actions as explained above.
Thanks
-Suresh
|