I have a Spring Application and use Hibernate5. I add a column dept_code
for many tables, and I want to add dept_code
query condition on the basis of the original query logic. For example:
before add dept_code column
select * from msg_template where status = "enable" and name like "test%";
select * from mini_page where groupId = -1 order by last_updated desc;
select * from customer where deleted = 0 order by last_updated desc limit 0 10;
after add dept_code column
select * from msg_template where status = "enable" and name like "test%" and (dept_code is null or dept_code = 'A');
select * from mini_page where groupId = -1 and (dept_code is null or dept_code = 'A') order by last_updated desc;
select * from customer where deleted = 0 and (dept_code is null or dept_code = 'A') order by last_updated desc limit 0 10;
There are so many query sql need to be add dept_code query condition, and the query sql will become very difficult to maintain if I modified all original query sql by adding dept_code query condition simply.
Is there a relatively good solution like sql intercetor that I do not need to modified query sql directly?
Aucun commentaire:
Enregistrer un commentaire