1. It is possible to construct HQL on the fly based on provided input, something like (approximate pseudo code):
StringBuffer sb = new StringBuffer( “from Product p where ” );
StringTokenizer st = new StringTokenizer(userInput);
While( st.hasMoreTokens()){
String keyword = st.nextToken();
sb.append( “p.name like ‘%”).append( escape( keyword) ).append(”%’”);
sb.append( “ or p.description like ‘%”).append( escape( keyword) ).append(”%’”);
}
This way is not very efficient and requires case independence at DB level to catch ‘Nike’ and ‘nike’.
2. Consider using search engines like:
DBSight
http://search.dbsight.com/
or Compass
http://compass.sourceforge.net/
see also discussion:
http://www.theserverside.com/news/threa ... d_id=35679