aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate and Triggers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate and Triggers" Watch "Hibernate and Triggers" New topic
Author

Hibernate and Triggers

kartik krishnan
Ranch Hand

Joined: Nov 19, 2006
Posts: 63
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?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate and Triggers