001: //$Id: NamedSQLQueryDefinition.java 11199 2007-02-13 21:04:24Z epbernard $
002: package org.hibernate.engine;
003:
004: import java.util.List;
005: import java.util.Map;
006:
007: import org.hibernate.FlushMode;
008: import org.hibernate.CacheMode;
009: import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
010:
011: /**
012: * Definition of a named native SQL query, defined
013: * in the mapping metadata.
014: *
015: * @author Max Andersen
016: */
017: public class NamedSQLQueryDefinition extends NamedQueryDefinition {
018:
019: private NativeSQLQueryReturn[] queryReturns;
020: private final List querySpaces;
021: private final boolean callable;
022: private String resultSetRef;
023:
024: /**
025: * This form used to construct a NamedSQLQueryDefinition from the binder
026: * code when a the result-set mapping information is explicitly
027: * provided in the query definition (i.e., no resultset-mapping used)
028: *
029: * @param query The sql query string
030: * @param queryReturns The in-lined query return definitions
031: * @param querySpaces Any specified query spaces (used for auto-flushing)
032: * @param cacheable Whether the query results are cacheable
033: * @param cacheRegion If cacheable, the region into which to store the results
034: * @param timeout A JDBC-level timeout to be applied
035: * @param fetchSize A JDBC-level fetch-size to be applied
036: * @param flushMode The flush mode to use for this query
037: * @param cacheMode The cache mode to use during execution and subsequent result loading
038: * @param readOnly Whether returned entities should be marked as read-only in the session
039: * @param comment Any sql comment to be applied to the query
040: * @param parameterTypes parameter type map
041: * @param callable Does the query string represent a callable object (i.e., proc)
042: */
043: public NamedSQLQueryDefinition(String query,
044: NativeSQLQueryReturn[] queryReturns, List querySpaces,
045: boolean cacheable, String cacheRegion, Integer timeout,
046: Integer fetchSize, FlushMode flushMode,
047: CacheMode cacheMode, boolean readOnly, String comment,
048: Map parameterTypes, boolean callable) {
049: super (query.trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
050: cacheable, cacheRegion, timeout, fetchSize, flushMode,
051: cacheMode, readOnly, comment, parameterTypes);
052: this .queryReturns = queryReturns;
053: this .querySpaces = querySpaces;
054: this .callable = callable;
055: }
056:
057: /**
058: * This form used to construct a NamedSQLQueryDefinition from the binder
059: * code when a resultset-mapping reference is used.
060: *
061: * @param query The sql query string
062: * @param resultSetRef The resultset-mapping name
063: * @param querySpaces Any specified query spaces (used for auto-flushing)
064: * @param cacheable Whether the query results are cacheable
065: * @param cacheRegion If cacheable, the region into which to store the results
066: * @param timeout A JDBC-level timeout to be applied
067: * @param fetchSize A JDBC-level fetch-size to be applied
068: * @param flushMode The flush mode to use for this query
069: * @param cacheMode The cache mode to use during execution and subsequent result loading
070: * @param readOnly Whether returned entities should be marked as read-only in the session
071: * @param comment Any sql comment to be applied to the query
072: * @param parameterTypes parameter type map
073: * @param callable Does the query string represent a callable object (i.e., proc)
074: */
075: public NamedSQLQueryDefinition(String query, String resultSetRef,
076: List querySpaces, boolean cacheable, String cacheRegion,
077: Integer timeout, Integer fetchSize, FlushMode flushMode,
078: CacheMode cacheMode, boolean readOnly, String comment,
079: Map parameterTypes, boolean callable) {
080: super (query.trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
081: cacheable, cacheRegion, timeout, fetchSize, flushMode,
082: cacheMode, readOnly, comment, parameterTypes);
083: this .resultSetRef = resultSetRef;
084: this .querySpaces = querySpaces;
085: this .callable = callable;
086: }
087:
088: /**
089: * This form used from annotations (?). Essentially the same as the above using a
090: * resultset-mapping reference, but without cacheMode, readOnly, and comment.
091: *
092: * FIXME: annotations do not use it, so it can be remove from my POV
093: * @deprecated
094: *
095: * @param query The sql query string
096: * @param resultSetRef The result-set-mapping name
097: * @param querySpaces Any specified query spaces (used for auto-flushing)
098: * @param cacheable Whether the query results are cacheable
099: * @param cacheRegion If cacheable, the region into which to store the results
100: * @param timeout A JDBC-level timeout to be applied
101: * @param fetchSize A JDBC-level fetch-size to be applied
102: * @param flushMode The flush mode to use for this query
103: * @param parameterTypes parameter type map
104: * @param callable Does the query string represent a callable object (i.e., proc)
105: */
106: public NamedSQLQueryDefinition(String query, String resultSetRef,
107: List querySpaces, boolean cacheable, String cacheRegion,
108: Integer timeout, Integer fetchSize, FlushMode flushMode,
109: Map parameterTypes, boolean callable) {
110: this (query, resultSetRef, querySpaces, cacheable, cacheRegion,
111: timeout, fetchSize, flushMode, null, false, null,
112: parameterTypes, callable);
113: }
114:
115: public NativeSQLQueryReturn[] getQueryReturns() {
116: return queryReturns;
117: }
118:
119: public List getQuerySpaces() {
120: return querySpaces;
121: }
122:
123: public boolean isCallable() {
124: return callable;
125: }
126:
127: public String getResultSetRef() {
128: return resultSetRef;
129: }
130: }
|