因为添加了转换规则,所以在pgadmin中可以直接使用varchar类型的字符串作为判断条件查询,但是使用mybatis查询数据库会报错operator does not exist
select*from sys_user where del_flag =0and role ='MALE'
解决方法:将varchar类型转成枚举类型再做比较
方式一
select*from sys_user where del_flag =0and role = cast(#{role} as user_role);
方式二
select*from sys_user where del_flag =0and role =#{role}::user_role;