`

Error applying BeanValidation relationa constraints

 
阅读更多

hibernate4.0.1,出现错误 Error applying BeanValidation relational constraints。

需要在hibernate.cfg.xml中添加

<property name="javax.persistence.validation.mode">none</property>

由于javax.persistence.validation.mode的属性值默认是auto,所以会出错。

在hibernate.cfg.xml里将javax.persistence.validation.mode设置为none即可。

 

详细错误:

2012-3-3 21:59:25 org.hibernate.validator.util.Version <clinit>
信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
Initial SessionFactory creation failed.org.hibernate.HibernateException: Error applying BeanValidation relational constraints
Exception in thread "main" java.lang.ExceptionInInitializerError
 at jp.co.ricoh.dao.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:29)
 at jp.co.ricoh.dao.util.HibernateUtil.<clinit>(HibernateUtil.java:16)
 at jp.co.ricoh.dao.impl.EmployeeDaoImpl.addEmployee(EmployeeDaoImpl.java:13)
 at jp.co.ricoh.domain.test.Test.main(Test.java:24)
Caused by: org.hibernate.HibernateException: Error applying BeanValidation relational constraints
 at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:219)
 at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:126)
 at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
 at jp.co.ricoh.dao.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:26)
 ... 3 more
Caused by: java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:208)
 ... 8 more
Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
 at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:524)
 at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:119)
 ... 13 more
Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.
 at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:272)
 at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
 at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:521)
 ... 14 more
Caused by: java.lang.NullPointerException
 at java.util.ResourceBundle.getBundle(Unknown Source)
 at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.loadBundle(ResourceBundleMessageInterpolator.java:202)
 at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.getFileBasedResourceBundle(ResourceBundleMessageInterpolator.java:182)
 at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:81)
 at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:73)
 at org.hibernate.validator.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:57)
 at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:43)
 at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269)
 ... 16 more

 

 

参考:http://www.howsky.net/index.php/archives/4630

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics