I am working on a Spring-MVC project using Hibernate as ORM and PostgreSQL as the database. In the project, I would like to search somee products in the database. As you can guess, the products have quite a few parameters like productName, productDescription, productTags, etc. Question : I am looking for a search function in HQL preferably where all the fields are searched and the productList is returned. I have a simmple search function as mentioned below.
Search function :
public List<ProductBasic> listProduct(Productname) {
if(session == null){
session = this.sessionFactory.openSession();
} else{
session = this.sessionFactory.getCurrentSession();
}
Query query = session.createQuery("from ProductBasic as p where p.productName=:productName order by p.ordernumber");
query.setParameter("productName",productName);
List<ProductBasic> productBasicList= query.list();
return productBasicList;
}