在Hibernate里使用Oracle的强制索引查询提示hints
在Hibernate Hql里使用数据库某些特殊的功能,例如使用Oracle的查询提示(hints)(如强制Oracle使用某个索引),使用用户自定义的数据库函数等,Hibernate的官方文档里已经有提到这个,不能使用Hql做数据库查询提示,而是使用三种Hibernate查询方法HQL,Criteria Queries,Native SQL里的Native SQL 本地SQL。如下:
Chapter 16. Native SQL
You may also express queries in the native SQL dialect of your database. This is useful if you want to utilize database specific features such as query hints or the CONNECT keyword in Oracle. It also provides a clean migration path from a direct SQL/JDBC based application to Hibernate.
Hibernate3 allows you to specify handwritten SQL (including stored procedures) for all create, update, delete, and load operations.
Query query = session.createSQLQuery("select /* CHOOSE */ {teste.*} from iqusuario {teste} ", "teste", iqTeste.class);