we are using hibernate to Insert/Update/Delete data in mysql db. whenever the hibernate query is fired it is shown on console. But my requirement is to store the query in db for audit purpose. hence i would require to store the query in a string variable so that i can further save it in db.
public int updatebarePumpData(Tbl13BarePumpData barePumpData)
{
    if (log.isInfoEnabled())
        log.info("start--BarePumpGADaoImpl---updatebarePumpData");
    int ans = 0;
    session = HibernateUtil.getSessionFactory().getCurrentSession();
    try
    {
        tx = session.beginTransaction();
        Tbl13BarePumpData barepumpObj = (Tbl13BarePumpData) session.load(Tbl13BarePumpData.class, barePumpData.getBarePumpdataId());
        barepumpObj.getBarePumpdataId();
        barepumpObj.setParameter(barePumpData.getParameter());
        barepumpObj.setValue(barePumpData.getValue());
        barepumpObj.setModifiedBy(barePumpData.getModifiedBy());
        barepumpObj.setModifiedDate(barePumpData.getModifiedDate());
        session.save(barepumpObj);
        tx.commit();
        ans = barepumpObj.getBarePumpdataId();
    }
    catch (Exception e)
    {
        if (tx != null && tx.isActive())
            tx.rollback();
        log.error(e.getMessage(), e);
    }
    if (log.isInfoEnabled())
        log.info("end--BarePumpGADaoImpl---updatebarePumpData");
    return ans;
}
The console output is
Hibernate: update pumpManagement_mp.dbo.tbl_13_barePump_data set barepumpga_id=?, parameter=?, value=?, createdBy=?, createdDate=?, modifiedBy=?, modifiedDate=?, company=? where barePumpdata_id=?
I would like to have the same Output in a variable
String qry=hibernate show query
Any help would be appreciated
Thanks & Regards, Pranav C Lunavat