christian wrote:
The filter in the book is for native Hibernate APIs. You can find it in the CaveatEmptor Hibernate (native) package.
If you want to have similar functionality for JPA, you should use an EJB 3.0 container instead and use EntityManager injection (and scope the transaction to the request somehow) or consider JBoss Seam. There is no API in Java Persistence that can handle a "current" and automaticallk propagated persistence context without an EJB3 runtime container. Hibernate can do that natively without a container.
It's not clear to me that I can easily use EJB3 in our current setup (we're using Resin; Resin 3.1.x has some other issues preventing us from moving to it yet, and I don't know offhand if it supports EJB3, either).
I can manage to store the Spring WebApplicationContext or our DAO beans in the current thread, making them available to the model objects, but I wasn't sure this was a sanctioned approach.
I don't mind using native Hibernate APIs; I don't need to be purely JPA. But I
do want to use annotations instead of XML files. If it turns out I can use EJB3 without too much pain with Resin (I don't want to switch to JBoss), then I can explore that. But it seems that I must read a great deal more about it to find out if it will even work for me, and I have not had time for that.
Thanks.