Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 743795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:54:17+00:00 2026-05-14T08:54:17+00:00

I have a hibernate filter that needs to evaluate using two different columns in

  • 0

I have a hibernate filter that needs to evaluate using two different columns in the database. I have another existing hibernate object that contains both of those fields, and I would like to be able to pass the other hibernate object into the session.enableFilter.setParameter() call, rather than pass both the values contained in it separately.

Specifically, I would like to replace this code:

session
     .enableFilter("inLocation")
     .setParameter("traversalLeft", 5)
     .setParameter("traversalRight", 10);

with this code:

session
     .enableFilter("inLocation")
     .setParameter("location", locationHibernateObject)

to better insulate excactly what the filter needs.

But when I try to configure the filter like:

@FilterDef(name="inLocation", parameters=@ParamDef( name="location", type="com.example.Location" ) )
@Filters( {
    @Filter(name="inLocation", condition="current_location_id in (select location.id from location where location.traversal_left between :location.traversalLeft+1 and :location.traversalRight)")
} )
public class ClassToFilter {

I get an error trying to call enableFilter()

Is this something that is even possible? What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:54:17+00:00Added an answer on May 14, 2026 at 8:54 am

    I have encountered the same problem it seems.

    I am using hibernate-annotations-3.4.0.GA, and my filters and custom types are in one package-info.java file. With that setup, the problem seems to be in:

    • org.hibernate.cfg.AnnotationBinder#bindPackage(), where filters are being processed before, rather then after custom types.
    • org.hibernate.cfg.AnnotationBinder#bindFilterDef(), that does not try to discover the custom types at all.

    I changed the calling order of methods, and replaced the call in bindFilterDef() with:

        private static void bindFilterDef(FilterDef defAnn, ExtendedMappings mappings) {
            Map params = new HashMap();
            for (ParamDef param : defAnn.parameters()) {
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                // support for custom types in filters
                params.put( param.name(), getType( param.type(), mappings ) );
            }
            FilterDefinition def = new FilterDefinition( defAnn.name(), defAnn.defaultCondition(), params );
            log.info( "Binding filter definition: {}", def.getFilterName() );
            mappings.addFilterDefinition( def );
        }
    
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // support for custom types in filters
        private static org.hibernate.type.Type getType(String paramType, ExtendedMappings mappings) {
            org.hibernate.type.Type heuristicType = TypeFactory.heuristicType( paramType );
            if ( heuristicType == null ) {
                org.hibernate.mapping.TypeDef typeDef = mappings.getTypeDef(paramType);
                if ( typeDef != null ) {
                    heuristicType = TypeFactory.heuristicType( typeDef.getTypeClass(), typeDef.getParameters() );
                }
            }
            log.debug( "for param type: {} parameter heuristic type : {}", paramType, heuristicType );
            return heuristicType;
        }
    

    Of course, then I had to build the jar from scratch, but the change seems to solve the problem.

    However, in Hibernate 3.5, annotation classes are bundled inside hibernate3.jar, so more work could be required, since everything has to be built from scratch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an object, A, which contains another object, B. We have Hibernate calling
I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
I have a hibernate object that gets detached and transferred to a thick java
I have a database that I have implemented Hibernate integration with. I was wondering
I am using Hibernate as the ORM for a database that has a number
I have hibernate configured to print out the sql statements that it generates and
I have a Hibernate mapping that looks something like this: <class name=MyEntity> <set name=scalarSet
I have a hibernate model with two classes, let's say A and B. B
I have two tables (tbArea, tbPost) that relate to the following classes. class Area
Imagine the following (simplified) database layout: We have many holiday records that relate to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.