| WildFly builds EntityManagerFactory, before CDI BeanManager is available. While EntityManagerFactory is being built, a named query that uses a converter will result in org.hibernate.metamodel.model.convert.internal.JpaAttributeConverterImpl#toRelationalValue attempting to use CDI BeanManager (before CDI BeanManager is available), which results in the NPE. After EntityManagerFactory is built, and, later, when CDI BeanManager is available, org.hibernate.resource.beans.container.spi.ExtendedBeanManager$LifecycleListener#beanManagerInitialized is called. Only after that happens, is it safe for Hibernate to compile the named query that uses a converter. |