1. hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
2013-03-27 09:11
489 查看
看hibernate的帮助文档,搜索validation,打开有道词典边翻译边看帮助文档,希望它能帮我,功夫不负有心人,终于让我找到了一段:
[html] view
plaincopy
23.1.1. Adding Bean Validation
To enable Hibernate's Bean Validation integration, simply add a Bean Validation provider (preferably Hibernate Validation 4) on your classpath.
23.1.2. Configuration
By default, no configuration is necessary.
The Default group is validated on entity insert and update and the database model is updated accordingly based on the Default group as well.
You can customize the Bean Validation integration by setting the validation mode. Use the javax.persistence.validation.mode property and set it up for example in your persistence.xml file or your hibernate.cfg.xml file. Several options are possible:
auto (default): enable integration between Bean Validation and Hibernate (callback and ddl generation) only if Bean Validation is present in the classpath.
none: disable all integration between Bean Validation and Hibernate
callback: only validate entities when they are either inserted, updated or deleted. An exception is raised if no Bean Validation provider is present in the classpath.
ddl: only apply constraints to the database schema when generated by Hibernate. An exception is raised if no Bean Validation provider is present in the classpath. This value is not defined by the Java Persistence spec and is specific to Hibernate.
注意
You can use both callback and ddl together by setting the property to callback, dll
<persistence
e028
...>
<persistence-unit ...>
...
<properties>
<property name="javax.persistence.validation.mode"
value="callback, ddl"/>
</properties>
</persistence-unit>
</persistence>
This is equivalent to auto except that if no Bean Validation provider is present, an exception is raised.
If you want to validate different groups during insertion, update and deletion, use:
javax.persistence.validation.group.pre-persist: groups validated when an entity is about to be persisted (default to Default)
javax.persistence.validation.group.pre-update: groups validated when an entity is about to be updated (default to Default)
javax.persistence.validation.group.pre-remove: groups validated when an entity is about to be deleted (default to no group)
org.hibernate.validator.group.ddl: groups considered when applying constraints on the database schema (default to Default)
Each property accepts the fully qualified class names of the groups validated separated by a comma (,)
这里大意就是在hibernate.cfg.xml或者是
我不知道是什么意思,我于是直接改我的hibernate.cfg.xml文件里添加属性:
[html] view
plaincopy
<property name="javax.persistence.validation.mode">none</property>
可怜的我居然hibernate居然不报错了。兴奋啊,javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个bean-validation**包,但是找不到,所以beanvalitionFactory错误。
[html] view
plaincopy
23.1.1. Adding Bean Validation
To enable Hibernate's Bean Validation integration, simply add a Bean Validation provider (preferably Hibernate Validation 4) on your classpath.
23.1.2. Configuration
By default, no configuration is necessary.
The Default group is validated on entity insert and update and the database model is updated accordingly based on the Default group as well.
You can customize the Bean Validation integration by setting the validation mode. Use the javax.persistence.validation.mode property and set it up for example in your persistence.xml file or your hibernate.cfg.xml file. Several options are possible:
auto (default): enable integration between Bean Validation and Hibernate (callback and ddl generation) only if Bean Validation is present in the classpath.
none: disable all integration between Bean Validation and Hibernate
callback: only validate entities when they are either inserted, updated or deleted. An exception is raised if no Bean Validation provider is present in the classpath.
ddl: only apply constraints to the database schema when generated by Hibernate. An exception is raised if no Bean Validation provider is present in the classpath. This value is not defined by the Java Persistence spec and is specific to Hibernate.
注意
You can use both callback and ddl together by setting the property to callback, dll
<persistence
e028
...>
<persistence-unit ...>
...
<properties>
<property name="javax.persistence.validation.mode"
value="callback, ddl"/>
</properties>
</persistence-unit>
</persistence>
This is equivalent to auto except that if no Bean Validation provider is present, an exception is raised.
If you want to validate different groups during insertion, update and deletion, use:
javax.persistence.validation.group.pre-persist: groups validated when an entity is about to be persisted (default to Default)
javax.persistence.validation.group.pre-update: groups validated when an entity is about to be updated (default to Default)
javax.persistence.validation.group.pre-remove: groups validated when an entity is about to be deleted (default to no group)
org.hibernate.validator.group.ddl: groups considered when applying constraints on the database schema (default to Default)
Each property accepts the fully qualified class names of the groups validated separated by a comma (,)
这里大意就是在hibernate.cfg.xml或者是
persistence.xml文件下面需要配置javax.persistence.validation.mode属性
我不知道是什么意思,我于是直接改我的hibernate.cfg.xml文件里添加属性:
[html] view
plaincopy
<property name="javax.persistence.validation.mode">none</property>
可怜的我居然hibernate居然不报错了。兴奋啊,javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个bean-validation**包,但是找不到,所以beanvalitionFactory错误。
相关文章推荐
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- 【转】hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate 错误:org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- 异常解决—org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- hibernate :org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- Spring JUnit org.hibernate.HibernateException: Unable to get the default Bean Validation factory
- spring整合hibernate出现HibernateException: Unable to get the default Bean Validation factory
- nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation fact
- spring整合hibernate出现HibernateException: Unable to get the default Bean Validation factory
- org.hibernate.HibernateException: Unable to get the default Bean Validation factor
- hibernate和spring整合:Unable to get the default Bean Validation factory
- Hibernate异常: Unable to get the default Bean Validation factory