• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Searching using multiple field

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 10 field as a search option All field are optional,means i can have value for a single field or for any no of fields or it may be a default search.How can i implement this? Can i use if else condition in my code or can i retrieve the result using a single query ? what will be the best option?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Hibernate Criteria Queries is one of the best options to go, when you have multiple search fields.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, this isn't really Portlet specific, but Hibernate Criteria is the way to go here. A criteria query looks something like this:




Here two properties are set for the user, but it could be 1, or it could be 10. Here's a tutorial on how to use the Hibernate Criteria API:

Using the Hibernate Criteria API

With a portlet, you only need to package the various libraries in the lib folder. The portal server will find them at runtime. That assumes you portal can interact directly with the database.

-Cameron McKenzie
reply
    Bookmark Topic Watch Topic
  • New Topic