Hibernate native SQL queries are bound to POJO or other sets, hibernatepojo
In addition to hql query, hibernate also supports native SQL query. However, we hope that native SQL queries can be bound to POJO, rather than Object objects, and encoding is required.
Hibernate provides createQuery and createSqlQuery interfaces to support hql queries and SQL queries.
Hql queries can be directly mapped to DO.
SQL query can be mapped to a specified object through query. addScalar (String columnAlias, Type type) and query. setResultTransformer (Transformers. aliasToBean (Entity. class.
ColumnAlias is the field alias and type is the database type provided in hibernate.
You can also use query. setResultTransformer (Transformers. AlIAS_TO_ENTITY_MAP) to place the query results in Map sets or other types of sets.
You can also map SQL queries to DO using query. addEntity.
For complex queries or multi-table queries, see: http://www.cnblogs.com/chenyixue/p/5601285.html
Http://blog.csdn.net/wangshfa/article/details/23543565