Is it possible to add hibernate filters in runtime ? Using annotations or filters in xbm isn't the way because user wants to create own filters and use them. Developers doesn't know all possible filters and can't add them to class. For example we have Owner and Cat, owner has many cats. And external users want to always use owner.getCats() to see current cats. But some users need to see only black cats, some green eyes and etc. And these filters' lifecycle is during one request.
- Posted by: Max Grigoriev
- Posted on: January 30 2008 14:11 EST
See Chapter 17(Filtering data) of the reference documentation. "Hibernate3 adds the ability to pre-define filter criteria and attach those filters at both a class and a collection level...The application can then make the decision at runtime whether given filters should be enabled and what their parameter values should be." session.enableFilter("myFilter").setParameter("myFilterParam", "some-value");