EntityManager and EntityManagerFactory are the only allowed types for a field/method annotated with @PersistenceContext/@PersistenceUnit. Weld does not allow values of other types to be injected (even if we wanted to, we are constrained by the type of the SPI http://docs.jboss.org/weld/javadoc/2.2/weld-spi/org/jboss/weld/injection/spi/JpaInjectionServices.html).
There are application servers that allow injection of Hibernate's Session or SessionFactory using @PersistenContext/@PersistenceUnit.
Due to the SPI type constraints we cannot offer this. We should however not block the integrator from doing this by overly strict validation rules if this is needed.
|