Announcement Announcement Module
Collapse
No announcement yet.
Parameter for Hibernate Filter? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 ?

    Background:
    Hibernate 3 provides this new feature: Filter
    see http://www.hibernate.org/hib_docs/v3...l/filters.html
    And I saw a fix in the JIRA ( http://opensource.atlassian.com/proj...browse/SPR-888 ) to enable Filters via
    Code:
    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:
    Code:
    session.enableFilter("userFilter").setParameter("userId", userId);
    But with HibernateTemplate this is missing.
    I would like to call something like:

    Code:
    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 =)

    Comment


    • #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 ?

      Comment


      • #4
        Since this topics gets some more attention I raised a feature request here:
        http://opensource2.atlassian.com/pro...rowse/SPR-1344

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

        Comment


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

          Code:
          /**
           * 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.

          Christian

          Comment

          Working...
          X