org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl#populate(SessionFactoryBuilder sfBuilder, StandardServiceRegistry ssr) does pass the correct VF to sfBuilder.applyValidatorFactory (using the ValidatorFactory passed to the EntityManagerFactoryBuilderImpl.withValidatorFactory). However, a bit later when we reach org.hibernate.cfg.beanvalidation.TypeSafeActivator#getValidatorFactory, we aren't using the SessionFactoryBuilder or EntityManagerFactoryBuilderImpl to obtain the VF. Instead, we are looking in the persistence unit properties. This sounds wrong to me.
On 07/08/2015 09:11 AM, Scott Marlow wrote: > > > On 07/08/2015 09:02 AM, Hardy Ferentschik wrote: >> Hi, >> >>> The same test works with the WildFly master branch, which is using ORM >>> 4.3.x. The Bean Validation integration code is unchanged in my WildFly >>> branch, as is the Bean Validator. The only thing different, is the ORM 5 >>> integration code and the ORM 5 persistence provider. >> >> Just fishing here, but "integration code and the ORM 5 persistence provider" >> might >> indicate a problem in the persistence bootstrapping. >> Have a look at >> org.hibernate.cfg.beanvalidation.TypeSafeActivator#getValidatorFactory. >> Basically ORM expects to retrieve the ValidatorFactory to use for the life >> cycle based >> validation from the properties passed via the Persistence bootstrap. The >> property name >> is javax.persistence.validation.factory. If there is no instance passed ORM >> will bootstrap >> a default factory using Validation.buildDefaultValidatorFactory(). The >> latter would >> of course not be CDI enabled. This would explain why validation occurs, but >> not CDI injection. >> I would for sure put a breakpoint in there as well (and some trace/debug log >> would be probably >> nice to have as well to easily tell whether a factory is passed or a default >> one is generated. > > Good suggestion, the validation factory does get passed in during the > second bootstrap phase. If we looked for it during the first JPA > bootstrap phase, we would not see it in Hibernate ORM 5. We should > check that. > >> >> --Hardy >> > _______________________________________________ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev