[hibernate-dev] No ValidatorFactory exposed through "javax.persistence.validation.factory" in WF 10 CR1

Gunnar Morling gunnar at hibernate.org
Wed Sep 23 09:24:46 EDT 2015


Scott,

Yes, EntityManagerFactoryBuilder#withValidatorFactory() is called (see
https://github.com/wildfly/wildfly/blob/10.0.0.CR1/jpa/subsystem/src/main/java/org/jboss/as/jpa/service/PersistenceUnitServiceImpl.java#L150,
I see it actually happening in the debugger), so I suppose Hibernate
ORM has the VF at its hands correctly.

Only that it is not exposed via the
"javax.persistence.validation.factory" key via the EMF-exposed
property map any more. So the call to

    entityManagerFactory().getProperties().get(
"javax.persistence.validation.factory" );

returns null whereas it used to return the VF in earlier versions.

But reading the spec again, it seems it only describes the
"javax.persistence.validation.factory" key as means of passing the VF
*to* JPA but not as means of obtaining it. Apparently that's just
something that happened to be the case in WF before, comments at the
test even states that this behaviour is not portable across
containers.

So I suppose I'll have to rework that test in the course of the upgrade.

--Gunnar


2015-09-23 14:51 GMT+02:00 Scott Marlow <smarlow at redhat.com>:
> Gunnar,
>
> In a standard bootstrap, the map parameter in the call to
> createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map),
> should have the ValidatorFactory.
>
> For the path that your debugging (2 phase bootstrap),
> org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder.withValidatorFactory(Object)
> should of been called.  If the Hibernate ORM version is 4.3 or 5.0, we
> should be calling EntityManagerFactoryBuilder.withValidatorFactory, could
> you check if that was called or not?
>
> Scott
>
>
> On 09/23/2015 07:38 AM, Gunnar Morling wrote:
>>
>> Scott,
>>
>> Upgrading the Hibernate Validator integration tests to run on WF 10
>> CR1, two tests fail for me DefaultValidatorFactoryInPersistenceUnitIT
>> and CustomValidatorFactoryInPersistenceUnitIT.
>>
>> These are about accessing the validator factory from the entity
>> manager factory through the "javax.persistence.validation.factory"
>> property. The look-up returns null, though. I tried to debug that a
>> bit but I am a bit lost in WF's PersistenceUnitServiceImpl. The code
>> in start() populates the property in a map, but that map is not used
>> for the EMF actually bootstrapped (which happens through the
>> EntityManagerFactoryBuilder
>> phaseOnePersistenceUnitService.getEntityManagerFactoryBuilder(), which
>> does not get this property set).
>>
>> Could you check this one out? Maybe JipiJapa's
>> EntityManagerFactoryBuilder should set that property to VF given via
>> withValidatorFactory()?
>>
>> Thanks,
>>
>> --Gunnar
>>
>> [1]
>> https://github.com/hibernate/hibernate-validator/blob/master/integration/src/test/java/org/hibernate/validator/integration/wildfly/DefaultValidatorFactoryInPersistenceUnitIT.java
>> [2]
>> https://github.com/hibernate/hibernate-validator/blob/master/integration/src/test/java/org/hibernate/validator/integration/wildfly/CustomValidatorFactoryInPersistenceUnitIT.java
>>
>


More information about the hibernate-dev mailing list