Working with ColdFusion 9 ORM, is there a way to trap entityDelete() errors 
when there's a constraint violation. I have my delete setup like so:

try {
       entityDelete(local.objSongCategory);
       // report success
} catch (Any e) {
       transaction action="rollback";
       // report fail
}

However, if I attempt to delete a record in use (a song assigned to category 
being deleted), CF throws an error:

coldfusion.orm.hibernate.HibernateSessionException: Cannot delete or update a 
parent row: a foreign key constraint fails (`databasename`.`songs`, CONSTRAINT 
`songs_ibfk_3` FOREIGN KEY (`SongCategoryID`) REFERENCES `songcategories` 
(`SongCategoryID`)). (Database)

I'm a little puzzled why the error isn't being caught since the delete is 
occurring inside a try/catch. Any thoughts? 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340211
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to