3.4.1.7. Query hints
Query hints (for performance optimization, usually) are implementation specific. Hints are declared using the query.setHint(String name, Object value) method, or through the @Named(Native)Query(hints) annotation Note that these are not SQL query hints! The Hibernate EJB3 implementation offers the following query hints:
Table 3.1. Hibernate query hints
Hint | Description |
---|---|
org.hibernate.timeout | Query timeout in seconds ( eg. new Integer(10) ) |
org.hibernate.fetchSize | Number of rows fetched by the JDBC driver per roundtrip ( eg. new Integer(50) ) |
org.hibernate.comment | Add a comment to the SQL query, useful for the DBA ( e.g. new String("fetch all orders in 1 statement") ) |
org.hibernate.cacheable | Whether or not a query is cacheable ( eg. new Boolean(true) ), defaults to false |
org.hibernate.cacheMode | Override the cache mode for this query ( eg. CacheMode.REFRESH ) |
org.hibernate.cacheRegion | Cache region of this query ( eg. new String("regionName") ) |
org.hibernate.readOnly | Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent ( eg. new Boolean(true) ), default to false |
org.hibernate.flushMode | Flush mode used for this query |
org.hibernate.cacheMode | Cache mode used for this query |
The value object accept both the native type or its string equivalent (eg. CaheMode.REFRESH or “REFRESH”). Please refer to the Hibernate reference documentation for more information.
No hay comentarios:
Publicar un comentario