I am using mysql 5.5 DB, hibernate.4.0 as jpa provider to spring 3.0.5.
I have a user table and privilege table in my DB. Also I have some triggers in my DB. Those trigger implements some of our application's business logic.
For example, user john insert a record into table table_foo via my web application.
- The trigger
BeforeInsertTableFoowill check the user's privilege. If user doesn't have the privilege, trigger will abort this operation. - Also, if the operation is permitted, another trigger
AfterInsertTableFoowill update some records in Tabletable_bar.
Is there any way that I can implement this logic as 'trigger' in java code? It seems like Jpa Event Listener and Hibernate Event can only do something like trigger but only in one table.
Surely I can use a java class to do the same thing. But I can't make sure that all the other developer, even myself, will use the correct java class to do db insertion or update, when the amount of business rules increased.
Thx in advance. andrew