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 8243409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:30:36+00:00 2026-06-07T21:30:36+00:00

I have a dynamic search with 25 optional parameters. HQl is not an option.

  • 0

I have a dynamic search with 25 optional parameters. HQl is not an option. I am using the Criterion API. I have DAO methods that I would like to accept a ‘Restriction’ List that I can build in my service layer such that, when I call my DAO method from the service as follows:

Lits<myPojoClass> = myDAO.getDataByCriterion( <?Restriction List?> )

myDAO.getDataByCriterion could consume the ‘Restriction List’ as follows:

inside the myDAO class

Public List<myPojoClass> getDataByCriterion( <?Restriction List?> restrictionList) {
    Session s = HibernateUtil.currentSession();
    Criteria c = s.createCriteria(myPojo.class)
                  .add(Restrictions ( <?Restriction List?>  );  //attach the list here
    List<myPojoClass> response = c.list();

It seems like somthing you should be able to do. Is it possible to add the restrictions passed into the DAO method

  • 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-06-07T21:30:37+00:00Added an answer on June 7, 2026 at 9:30 pm

    Yes, it’s possible. Your Restriction List should be a regular List of Criterion objects (i.e., List <Criterion>). Just to be clear, if you add them all like your sample code, you’re gonna be doing a conjunction (a series of logical ANDs).

    Adding my suggestion to your code gives this:

    Public List<myPojoClass> getDataByCriterion( List<Criterion> restrictionList) {
    Session s = HibernateUtil.currentSession();
    Criteria c = s.createCriteria(myPojo.class);
    for (Criterion crit : restrictionList){
        c.add(crit);
    }
    
    List<myPojoClass> response = c.list();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a search that have a dynamic number of checkboxes and a price
I have UI where a user can search on optional parameters.I am writing a
Say I have a page that contains dynamic content (e.g. search results). What is
I have a dynamic SQL search that im having a problem with on the
I have search the net and not found anything that has helped, so thought
I have a dynamic search query with join multiple tables, for showing sum and
I have some divs that have dynamic heights controlled by a 'click' function as
I have some divs that have dynamic heights controlled by a 'click' function as
I have a dynamic text file that picks content from a database according to
I have a dynamic list of items that will be used to POST information

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.