I want to set show_sql hibernate parameter inside java code in hibernate method, so that it can print the actual SQL query for that specific method only.
I Know using below configuration it can be done
<property name="show_sql">true</property>
But it will print all sql for all hibernate calls. I want specific for few methods
Ex.
public List<Customer> getAllCustomerListByActive(boolean isActive) {
List<Customer> customerList = new ArrayList<Customer>();
Criteria criteria = getSession().createCriteria(Customer.class);
criteria.add(Restrictions.eq("isActive", isActive));
criteria.add(Restrictions.eq("delFlag", false));
criteria.addOrder(Order.asc("id"));
customerList = criteria.list();
**//Print SQL Method Syntax will come here**
return customerList;
}
@Vash has given link above, which has detailed the different approaches.
But for reference to this question, and which I have used in my code is as below
Its very very risky to use for Production Environment.