hibernate-validator

Trouble starting Hibernate Validator due to Bean Validation API

隐身守侯 提交于 2019-11-27 03:11:39
问题 I'm trying to use Hibernate Validator in my project, but it isn't working. On the following line: SessionFactory sessions = config.buildSessionFactory(builder.build()); I get the following exception: org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:154) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:311) at org

Use custom validation messages in Hibernate + Spring

≡放荡痞女 提交于 2019-11-27 02:52:35
问题 I tried the steps from the answer here: Hibernate Validator, custom ResourceBundleLocator and Spring But still just getting {location.title.notEmpty} as output instead of the message. dispatcher-servlet.xml <bean name="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <property name="validationMessageSource"> <ref bean="resourceBundleLocator"/> </property> </bean> <bean name="resourceBundleLocator" class="org.springframework.context.support

Cross field validation with HibernateValidator displays no error messages

﹥>﹥吖頭↗ 提交于 2019-11-27 01:02:42
问题 I'm validating two fields, "password" and "confirmPassword" on the form for equality using HibernateValidator as specified in this answer. The following is the constraint descriptor (validator interface). package constraintdescriptor; import constraintvalidator.FieldMatchValidator; import javax.validation.Constraint; import javax.validation.Payload; import java.lang.annotation.Documented; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation

javax.validation.ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'

泄露秘密 提交于 2019-11-26 22:15:58
问题 I try to write very simple application with hibernate validator: my steps: add following dependency in pom.xml: <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.1.1.Final</version> </dependency> write code: class Configuration { Range(min=1,max=100) int threadNumber; //... public static void main(String[] args) { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Configuration

Hibernate - Error activating Bean Validation integration

混江龙づ霸主 提交于 2019-11-26 22:02:54
问题 I am trying to set up Hibernate. But when i try to create my Session Factory, with this code: Configuration configuration = new Configuration(); configuration.configure(); serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); I get the error: org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration at org.hibernate.cfg

JSR-303 validation with custom message

混江龙づ霸主 提交于 2019-11-26 21:24:51
问题 I'm using Spring 3.0.5-RELEASE, with JSR-303 style validation and Hibernate validator 4.1.0-Final. My model class looks something like this: public class Model { @Max(value=10,message="give a lower value") Integer n; } And this is passed as request param in a spring mvc servlet with binding. So the request would look something like this: http://localhost:8080/path?n=10 What I want is to be able to customize the error message when there is a type mismatch exception, e.g. http://localhost:8080

javax.servlet.ServletException: HV000030: No validator could be found for type: java.lang.Integer

こ雲淡風輕ζ 提交于 2019-11-26 20:07:55
问题 I have to update information in my database. FacadePatient.java class code: public Patient update(Patient p) { Patient pat = em.find(Patient.class, p.getPatientId()); p.setPatientPhone(pat.getPatientPhone()); p.setPatientDateNaiss(pat.getPatientDateNaiss()); p.setPatientEmail(pat.getPatientEmail()); p.setPatientJob(pat.getPatientJob()); p.setPatientSmoking(pat.getPatientSmoking()); p.setPatientSize(pat.getPatientSize()); em.merge(pat); return p; } 回答1: HV000030: No validator could be found

AbstractMethodError on deploying Spring 4.0 in Tomcat 6

大兔子大兔子 提交于 2019-11-26 17:41:57
问题 I am getting below exception on deploying Spring 4.0.1 app in Tomcat 6.0.37: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.hibernate.validator.internal

Hibernate Validation of Collections of Primitives

家住魔仙堡 提交于 2019-11-26 15:08:28
I want to be able to do something like: @Email public List<String> getEmailAddresses() { return this.emailAddresses; } In other words, I want each item in the list to be validated as an email address. Of course, it is not acceptable to annotate a collection like this. Is there a way to do this? Neither JSR-303 nor Hibernate Validator has any ready-made constraint that can validate each elements of Collection. One possible solution to address this issue is to create a custom @ValidCollection constraint and corresponding validator implementation ValidCollectionValidator . To validate each

Validate class level bean validation constraints in JSF

寵の児 提交于 2019-11-26 14:56:00
问题 It seems that JSF 2.0 does not call "class level constraints". Quoting from an SO answer JSF 2.0 doesn't call class level validation constraints. From JSF validation: JSF 2 provides built-in integration with JSR-303 constraints. When you are using bean validation in your application, JSF automatically uses the constraints for beans that are referenced by UIInput values. The answer furthermore suggests using SeamFaces to validate the class-level constraints anyways. Unfortunately this is a non