Pergunta

I have a few Hibernate Envers listeners which I use for audit purposes. I am just getting started on CDI and so far am pleasantly surprised by its simplicity and power. Since it seems everything is integrating CDI functionality, I thought I'd raise the question, is Hibernate supporting it or will it?

Not only would it be nice to have access to various components, but it would also be great to have access to other contextual information easily and not be limited by Hibernate's interfaces.

Foi útil?

Solução

The question should be the other way around - will CDI support hibernate integration.

What CDI has to support, probably via an extension, is:

  • injecting an EntityManager where there is @PersistenceContext, and EntityManagerFactory where there is @PersistenceUnit
  • transaction and session lifecycle handling

Google for "Weld Persistence Context" and you'll get some examples of how to use Hibernate (JPA) with Weld, which is the reference implementation of CDI. Read this thread as well. And this example

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top