whummer / jaxb-facets

Support for extended XSD features in JAXB: facets (restrictions on simple types), annotations, asserts, ...
Other
26 stars 18 forks source link

javax.validation.UnexpectedTypeException when using @Facets to other types except String #5

Closed ageorgousakis closed 11 years ago

ageorgousakis commented 11 years ago

The @Facets has as validator FacetsValidator which expects a String as the type to validate.

When an Integer or BigDecimal is annotated with @Facets annotation and try to persist a JPA entity with hibernate I get the following exception

javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.math.BigDecimal. at org.hibernate.validator.internal.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:411) at org.hibernate.validator.internal.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:392) at org.hibernate.validator.internal.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:350) at org.hibernate.validator.internal.engine.ConstraintTree.validateConstraints(ConstraintTree.java:171) at org.hibernate.validator.internal.engine.ConstraintTree.validateConstraints(ConstraintTree.java:124) at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:86) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:442) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:387) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:351) at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:303) at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:133) at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:136) at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:94) at org.hibernate.action.internal.EntityInsertAction.preInsert(EntityInsertAction.java:181) at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:81) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:377) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:369) at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:286) at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234) at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:996) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:241) at com.sun.proxy.$Proxy82.flush(Unknown Source)

ageorgousakis commented 11 years ago

I saw that you removed the FacetsValidator for the annotation. Now the problem no longer exists.