Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-17543

Delay start of second Hibernate ORM Persistence bootstrap phase until after jakarta.enterprise.inject.spi.AfterDeploymentValidation

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Major
    • None
    • None
    • JPA / Hibernate
    • None

    Description

      The root issue is that in Hibernate 6.2, custom user types which may be CDI beans as they were in previous releases but due to design changes Hibernate ORM 6.2 now needs to process the custom user types during the second Persistence Unit bootstrap phase. See https://hibernate.atlassian.net/browse/HHH-16069 for more info.

      I'm thinking that we could try a change to start Hibernate when the jakarta.enterprise.inject.spi.AfterDeploymentValidation event is called by WeldStartService. Currently the WeldStartService is started after the Persistence unit is completely deployed so this would be a change that only happens if CDI is enabled for the persistence unit + deployment.

      https://gist.github.com/scottmarlow/b0e17c801b2cd712ad1b598c555d7e4b shows the current call stack of WeldStartService handling the jakarta.enterprise.inject.spi.AfterDeploymentValidation event (which calls org.jboss.as.jpa.beanmanager.BeanManagerAfterDeploymentValidation#afterDeploymentValidation) from which we currently notify Hibernate that the Bean Manager is available for use.

      I think ^ could impact CDI injected persistence units but we recently changed the handling code to use a lazy factory if needed (https://github.com/wildfly/wildfly/blob/main/weld/jpa/src/main/java/org/jboss/as/weld/services/bootstrap/WeldJpaInjectionServices.java#L83 which was for https://issues.redhat.com/browse/WFLY-14923). So I think that case would be okay.

      I'll prototype a change for ^ but am very interested in any feedback on the idea.

      https://hibernate.atlassian.net/browse/HHH-16069

      Attachments

        Activity

          People

            smarlow1@redhat.com Scott Marlow
            smarlow1@redhat.com Scott Marlow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: