This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a two tables t_profile and t_loan where t_loan has a standard foreign key relationship with t_profile (pk of t_profile is a fk in t_loan). I am implementing a trigger that will store an audit entry in the table t_loan_history when the loan is deleted for that profile.
Objects of type Loan and Profile are mapped to the table using hibernate mapping xml file.
To delete the loan from the web app , I am using HibernateTemplate to delete the loan as shown below:
I have a history table which is a mirror of the loan table in addition it's own primary key.
My trigger code to create loan delete audit:
When I run this code, this is the error that I get
However, ordinary sql query
to delete the loan from t_loan table deletes the loan entry and populates the history audit entry.