When using hibernate SQL queries in multi-table queries, the object[] array is generally returned, or you can use the
Session.createsqlquery (SQL). Setresulttransformer (Transformers.alias_to_entity_map); Session. Session.createsqlquery (SQL). addentity (Entity.class); /**
* Paged Query Sql,sql statement does not contain the number of start records and query records
* @param sql
* @param params
* @param start
* @param limit
* @return
*/
Public list<object[]> Pagequerysql2array (String sql, object[] params, int start,
int limit) {
SQLQuery query = (sqlquery) initpagequery (SQL, params, start, limit,
False). Setresulttransformer (Transformers.aliastobean (Entityclass));
Return (list<object[]>) query.list ();
} /**
* Get generic type
*
* @return
*/
@SuppressWarnings ("Unchecked")
Protected class<t> Getgenericclass () {
Parameterizedtype type = (Parameterizedtype) getclass ()
. Getgenericsuperclass ();
Return (class<t>) type.getactualtypearguments () [0];
}
Hibernate SQL query object converted to entity class