Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Searching using multiple field

 
sahidul karim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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?
 
Hemant Sharma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Hibernate Criteria Queries is one of the best options to go, when you have multiple search fields.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic