Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and Triggers

 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Code:



However, ordinary sql query



to delete the loan from t_loan table deletes the loan entry and populates the history audit entry.

Am I doing anything wrong?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic