Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching using multiple field  RSS feed

 
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?
 
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.
 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!