I want to bind multiple parameters with this query dynamically,
Query selectList = session.createSQLQuery("select * from Txn where recNo =: recNo")
.addEntity(Txn.class);
selectist.setParameter("recNo",recNo);
selectTxnList.setFirstResult(startRowNo);
selectTxnList.setMaxResults(scrollValue);
List list = selectTxnList.list();
Suppose here i check that if i have not null in txnNo then i want to bind this parameter also with this query
Example - select *from Txn where recNo = 123 and txnNo = txnNo;
and if i have null in txnNo then i only want to bind recNo with this query.
Example - select *from Txn where recNo = 123;
Please tell me the way if i can do this with the help of HQL, because i have more than 50 parameters. i dont want to increase the parameter the the query(select * from Txn where recNo =: recNo )
ifstatement in your Java logic to handle this?