hibernate-validator

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

我怕爱的太早我们不能终老 提交于 2019-11-27 20:03:49
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; } HV000030: No validator could be found for type: java.lang.Integer That will happen when you use JSR303 bean validation in flavor of Hibernate

Hibernate validator: @Email accepts ask@stackoverflow as valid?

独自空忆成欢 提交于 2019-11-27 17:26:44
I'm using the @Email annotation to validate an e-mail address. The issue I'm having is that it's accepting things like ask@stackoverflow as a valid e-mail address. I guess this is because they want to support intranet addresses, but I can't seem to find a flag so it does check for an extension. Do I really need to switch to @Pattern (and any recommendations for an e-mail pattern that's flexible) or am I missing something? axtavt Actually, @Email from Hibernate Validator uses regexp internally . You can easily define your own constraint based on that regexp, modified as you need (note the + at

Spring MVC 3 Validation - Unable to find a default provider

天大地大妈咪最大 提交于 2019-11-27 13:29:08
问题 I get an error when trying to set up Spring MVC validation. javax.validation.ValidationException: Unable to find a default provider I read in the documents that the default provider they use is the hibernate-validator. Do I need to include this library to get validation to work? Is it okay to include this library even though i'm not using hibernate for my project? 回答1: Yes, you should include Hibernate Validator library in order to use it. It doesn't depend on Hibernate itself. 回答2: If you

JSR 303: How to Validate a Collection of annotated objects?

ぐ巨炮叔叔 提交于 2019-11-27 13:25:24
问题 Is it possible to validate a collection of objects in JSR 303 - Jave Bean Validation where the collection itself does not have any annotations but the elements contained within do? For example, is it possible for this to result in a constraint violation due to a null name on the second person: List<Person> people = new ArrayList<Person>(); people.add(new Person("dave")); people.add(new Person(null)); Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); Set

javax.validation.ValidationException: Unable to find default provider

十年热恋 提交于 2019-11-27 12:00:47
问题 I am currently working on Spring MVC web app and trying to hook up validation using the @Valid annotation. When I fire up the application I'm getting the following exception: javax.validation.ValidationException: Unable to find a default provider I have Hibernate Validator 3.1.0.GA on the classpath as well as javax validation 1.0.0.GA, Hibernate Core 3.3.1.GA and Hibernate Annotations 3.4.0.GA. Is there an incompatiblity in those versions that I'm not seeing, or can anyone think of any reason

Validate class level bean validation constraints in JSF

和自甴很熟 提交于 2019-11-27 09:47:45
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-option, since it introduces a somewhat massive dependency for just validating what should be validated

AbstractMethodError on deploying Spring 4.0 in Tomcat 6

匆匆过客 提交于 2019-11-27 07:45:58
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.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider; at

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

梦想的初衷 提交于 2019-11-27 06:56:31
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 configuration = new Configuration(); configuration.threadNumber = 12; //... Set<ConstraintViolation

How to validate dynamically generated fields server side

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:06:58
问题 I have developed a web application using Spring 3.1 In one of the module I need to save one Operation object having many OperationParameter objects. So in the view I have provided add button for user to create OperationParameters for the particular Operation. Both the models have hibernate mapping and there is one to many relation between Operation and OperationParameter. And in Operation model I have List of OperationParameters that will be inserted in database when a new Operation will be

How do I dynamically resolve message parameters with Hibernate Validator?

只愿长相守 提交于 2019-11-27 03:19:23
问题 I'm using Hibernate Validator and would like to resolve the category's name in an error message. Consider this simple scenario: public class Category { private String name; } public class Product { @HazardousCategoryConstraint(message = "{haz.cat.error}") private Category category; private String name; } public class InventoryReport { @Valid private List<Product> products; } ValidationMessages.properties haz.cat.error={name} is a product in the hazardous category list. Assume that I have a