Announcement Announcement Module
No announcement yet.
Parameter for Hibernate Filter? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parameter for Hibernate Filter?

    Are there any plans of supporting not only the enabling of Filters, but also the parameterizing of it in HibernateTemplate ?

    Hibernate 3 provides this new feature: Filter
    And I saw a fix in the JIRA ( ) to enable Filters via
    HibernateAccessor.setFilterName(String filter)
    So far, so good. The Problem comes in with Parameters for this Filter.
    Within my custom HibernateCallback I can do something like:
    session.enableFilter("userFilter").setParameter("userId", userId);
    But with HibernateTemplate this is missing.
    I would like to call something like:

    getHibernateTemplate().setFilterName("userFilter").setParameter("userId", filter.getUserID());
    Am I missing something? or are there already any plans for supporting this? Should I place this into Springs JIRA?

  • #2
    Is there any progress with the issue about enabling filter parameters passing thru HibernateTemplate?
    Looks like filters from Hibernate3 is gettging known widly =)


    • #3
      What is the benifit of getHibernateTemplate.enableFilter(name) if we still need to do the 'seesion.setFilterName(name).setParameter()' to setup values for filter's paramers ?

      It looks like it is only useful for parameterless filters, but i bet the large amount of filters will actually do have paramers, since this is the filter used for.

      So, is there any plans to add support for paramers initiazliation in HibernateTemplate ?


      • #4
        Since this topics gets some more attention I raised a feature request here:

        I know it is wrongly classified as a bug, but it really is a feature request.


        • #5
          Look at the signature/documentation for enableFilter(...):

           * Return an enabled Hibernate Filter for the given filter name.
           * The returned Filter instance can be used to set filter parameters.
           * @param filterName the name of the filter
           * @return the enabled Hibernate Filter (either already enabled
           * or enabled on the fly by this operation)
           * @throws IllegalStateException if we are not running within a
           * transactional Session (in which case this operation does not make sense)
          Filter enableFilter(String filterName) throws IllegalStateException;
          "The returned Filter instance can be used to set filter parameters."

          It returns the enabled Filter object, and then you can set any parameters required for the filter to actually be applied.