-->
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.  [ 3 posts ] 
Author Message
 Post subject: Disable/re-enable of Filter
PostPosted: Mon Jan 14, 2008 7:38 am 
Newbie

Joined: Mon Jan 14, 2008 7:08 am
Posts: 2
Hibernate version: 3.2

I am using Hibernate Filters to implement temporal versioning of data. I have a routine that is used to update temporal data sets that should run without the filter.

I therefore need to disable the filter before the update and reenable the filter after the update. I need to copy and save the current Filter parameters to set when I re-enable the Filter.

My problem is that the Filter interface does not give access to the current Filter parameter values. It does give access to the names via the FilterDefinition but again not the values.

FilterImpl (the implementation of the Filter interface) does have a method getParameter that does give access to the parameter values. At the moment if I cast the Filter returned from the session.getEnableFilter to a FilterImpl I can get the parameters. However I do not think that it is technically appropriate to follow this course of action.

Please note that if you disable a Filter and then Enable it – a new Filter instance is created without any of the previous parameters set.

I would prefer not to have to save the Filter values elsewhere for reuse as these would have to be made available in all classes that may use the update facility.

Question
1. Does anyone temporarily disable a re-enable Filters – if so how do you do this?
2. Am I being too correct is not wanting to cast the Filter to a FilterImpl?
3. Was there a good reason that the getParameter method is not specified in the Filter interface?


Top
 Profile  
 
 Post subject: Disable/re-enable of Filter
PostPosted: Tue Jan 15, 2008 11:33 am 
Newbie

Joined: Sat Nov 22, 2003 11:49 am
Posts: 11
Location: Minneapolis, Minnesota
I simply call session.enableFilter(...), or session.disableFilter(...). My filter params don't get reset.

Are you programmatically defining your filters, or by static config (annotation or hbm.xml)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 11:54 am 
Newbie

Joined: Mon Jan 14, 2008 7:08 am
Posts: 2
The filter is defined in the hbm.xml file.

I am using session.enableFilter(String) and session.disableFilter(String).

If you look at the code in sessionImpl....

Code:
   public Filter enableFilter(String filterName) {
      errorIfClosed();
      checkTransactionSynchStatus();
      FilterImpl filter = new FilterImpl( factory.getFilterDefinition(filterName) );
      enabledFilters.put(filterName, filter);
      return filter;
   }

... you can see that a new Filter is created each time.
As the parameters are stored in the Filter instance I cannot see how your system can be maintaining its parameters.


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

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.