java禁用特定方法的Hibernate验证
我想禁用特定方法中的hibernate验证。例如,将验证保留为正常保存,并禁用它们以在不使用验证方法的情况下保存。是否可以通过一些注释来实现这一点
我知道它可以在具有以下属性的配置中禁用:
<Validation-mode> NONE </ validation-mode>
我实际上只是在带有@Valid注释的控制器上对表单错误进行验证。要插入到数据库中,我不需要
我的有效解决方案:
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
...
Properties jpaProperties = new Properties();
jpaProperties.put("javax.persistence.validation.mode", "NONE");
factory.setJpaProperties(jpaProperties);
# 1 楼答案
尝试使用Validating Groups: