Kaw*_*awu 7 validation hibernate
如何在JPA 1.0环境中使用Hibernate 3.x关闭bean验证?
我用persistence.xml尝试了几件事:
<persistence-unit name="bbstats" transaction-type="RESOURCE_LOCAL">
<properties>
DB stuff
<property name="javax.persistence.validation.mode" value="none" />
<property name="hibernate.validator.autoregister_listeners" value="false" />
</properties>
<validation-mode>NONE</validation-mode>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)
最后一个导致
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'validation-mode'. One of '{"http://java.sun.com/xml/ns/persistence":jta-data-source, "http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
Run Code Online (Sandbox Code Playgroud)
但没有上述工作.谁能告诉我如何在JPA 1.0实现上做到这一点?
该javax.persistence.validation.mode物业是JPA 2.0的标准物业之一.它不会指望它在JPA 1.0环境中工作.
实际上,假设你正在使用Hibernate Validator 4,我的建议是从类路径中删除JAR(我不确定Hibernate Validator 3的配置设置是否仍然适用).
如果您使用的是Hibernate Validator 3,则在插入或更新之前,以下内容应禁用生成的DDL和实体验证中的约束支持:
<property name="hibernate.validator.apply_to_ddl" value="false"/>
<property name="hibernate.validator.autoregister_listeners" value="false"/>
Run Code Online (Sandbox Code Playgroud)
但是从类路径中删除JAR也是直截了当的.
如果您遇到更具体的问题,请提供更具体的详细信息(包括Hibernate Validator的版本).
| 归档时间: |
|
| 查看次数: |
11938 次 |
| 最近记录: |