I use Hibernate 3 with JBoss 4.2.2 GA. In my Beans I use the injected instance of a Hibernate session:
Code:
@PersistenceContext(unitName="MyUnit")
private Session session;
In some of Annotation-Mapped Hibernate classes I define filters. As the Hibernate reference says,
Quote:
By default, filters are not enabled for a given session; they must be explcitly enabled through use of the Session.enableFilter() method, which returns an instance of the Filter interface.
But all my filters, which I defined, must be applied to the appropriated mapped classes. To activate the filters I must in every my session bean that uses the injected Hibernate session enable the filters through the call
Code:
session.enableFilter("myFilter")
This is not a good solution, beacuse I repeat this code on every bean, and I must explicitly enable EVERY filter from all entities that are used in the current EJB bean. In the not managed environment I would use an intrceptor to initialize the Hibernate Session. But using JBoss, I get the Session instance from AS and have no control of the instantiating or initialising of the Session. Is there a way to enable all filters of a session?