-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Enable all Hibernate Filters per default
PostPosted: Sun Nov 23, 2008 6:47 am 
Beginner
Beginner

Joined: Mon Dec 05, 2005 4:15 am
Posts: 36
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.