These are chat archives for hibernate/hibernate-orm

Mar 2016
Mar 23 2016 15:05
hi all
someone know how to convert sql from hql ?
I want use Queryobject to output a sql string
Johno Crawford
Mar 23 2016 15:07
not sure about getting the output from a query programatically, but you can always enable these two properties
    // If the value of this property is true, Hibernate writes all SQL statements to the console.
    properties.put("hibernate.show_sql", false);

    // If the value of this property is true, Hibernate will use prettyprint when it writes SQL to the console.
    properties.put("hibernate.format_sql", false);
Mar 23 2016 15:11
@johnou thanks,but I need use sql,not just show it
Mar 23 2016 15:46
I want to know when that hibernate mapping a Bean Type with data
Query countQuery = sessionFactory.openSession().createQuery("select new Map(count(*) as count) from UserInfo where mainId in (select mainId from UserInfo)");
there is my code , a count query , that sub query is a simple query,but on the real time , I need add some clause with that query, but finally I just need a count number (that mean , If on this moment hibernate put all sub query mapping a Object instance,will take a lot of memory)
so,how to work in this long hql query (countQuery)
Mar 23 2016 15:52
someone here , I need some help ,pls.