QueryParameterspublic final class QueryParameters extends Object
Fields Summary |
---|
private static final Log | log | private org.hibernate.type.Type[] | positionalParameterTypes | private Object[] | positionalParameterValues | private Map | namedParameters | private Map | lockModes | private RowSelection | rowSelection | private boolean | cacheable | private String | cacheRegion | private String | comment | private org.hibernate.ScrollMode | scrollMode | private Serializable[] | collectionKeys | private Object | optionalObject | private String | optionalEntityName | private Serializable | optionalId | private boolean | readOnly | private boolean | callable | private boolean | autodiscovertypes | private boolean | isNaturalKeyLookup | private final org.hibernate.transform.ResultTransformer | resultTransformer | private String | processedSQL | private org.hibernate.type.Type[] | processedPositionalParameterTypes | private Object[] | processedPositionalParameterValues |
Constructors Summary |
---|
public QueryParameters()
this( ArrayHelper.EMPTY_TYPE_ARRAY, ArrayHelper.EMPTY_OBJECT_ARRAY );
| public QueryParameters(org.hibernate.type.Type type, Object value)
this( new Type[] {type}, new Object[] {value} );
| public QueryParameters(org.hibernate.type.Type[] positionalParameterTypes, Object[] postionalParameterValues, Object optionalObject, String optionalEntityName, Serializable optionalObjectId)
this(positionalParameterTypes, postionalParameterValues);
this.optionalObject = optionalObject;
this.optionalId = optionalObjectId;
this.optionalEntityName = optionalEntityName;
| public QueryParameters(org.hibernate.type.Type[] positionalParameterTypes, Object[] postionalParameterValues)
this(
positionalParameterTypes,
postionalParameterValues,
null,
null,
false,
null,
null,
false,
null
);
| public QueryParameters(org.hibernate.type.Type[] positionalParameterTypes, Object[] postionalParameterValues, Serializable[] collectionKeys)
this(
positionalParameterTypes,
postionalParameterValues,
null,
collectionKeys
);
| public QueryParameters(org.hibernate.type.Type[] positionalParameterTypes, Object[] postionalParameterValues, Map namedParameters, Serializable[] collectionKeys)
this(
positionalParameterTypes,
postionalParameterValues,
namedParameters,
null,
null,
false,
false,
null,
null,
collectionKeys,
null
);
| public QueryParameters(org.hibernate.type.Type[] positionalParameterTypes, Object[] positionalParameterValues, Map lockModes, RowSelection rowSelection, boolean cacheable, String cacheRegion, String comment, boolean isLookupByNaturalKey, org.hibernate.transform.ResultTransformer transformer)
this(
positionalParameterTypes,
positionalParameterValues,
null,
lockModes,
rowSelection,
false,
cacheable,
cacheRegion,
comment,
null,
transformer
);
isNaturalKeyLookup = isLookupByNaturalKey;
| public QueryParameters(org.hibernate.type.Type[] positionalParameterTypes, Object[] positionalParameterValues, Map namedParameters, Map lockModes, RowSelection rowSelection, boolean readOnly, boolean cacheable, String cacheRegion, String comment, Serializable[] collectionKeys, org.hibernate.transform.ResultTransformer transformer)
this.positionalParameterTypes = positionalParameterTypes;
this.positionalParameterValues = positionalParameterValues;
this.namedParameters = namedParameters;
this.lockModes = lockModes;
this.rowSelection = rowSelection;
this.cacheable = cacheable;
this.cacheRegion = cacheRegion;
//this.forceCacheRefresh = forceCacheRefresh;
this.comment = comment;
this.collectionKeys = collectionKeys;
this.readOnly = readOnly;
this.resultTransformer = transformer;
| public QueryParameters(org.hibernate.type.Type[] positionalParameterTypes, Object[] positionalParameterValues, Map namedParameters, Map lockModes, RowSelection rowSelection, boolean readOnly, boolean cacheable, String cacheRegion, String comment, Serializable[] collectionKeys, Object optionalObject, String optionalEntityName, Serializable optionalId, org.hibernate.transform.ResultTransformer transformer)
this(
positionalParameterTypes,
positionalParameterValues,
namedParameters,
lockModes,
rowSelection,
readOnly,
cacheable,
cacheRegion,
comment,
collectionKeys,
transformer
);
this.optionalEntityName = optionalEntityName;
this.optionalId = optionalId;
this.optionalObject = optionalObject;
|
Methods Summary |
---|
public org.hibernate.engine.QueryParameters | createCopyUsing(RowSelection selection)
QueryParameters copy = new QueryParameters(
this.positionalParameterTypes,
this.positionalParameterValues,
this.namedParameters,
this.lockModes,
selection,
this.readOnly,
this.cacheable,
this.cacheRegion,
this.comment,
this.collectionKeys,
this.optionalObject,
this.optionalEntityName,
this.optionalId,
this.resultTransformer
);
copy.processedSQL = this.processedSQL;
copy.processedPositionalParameterTypes = this.processedPositionalParameterTypes;
copy.processedPositionalParameterValues = this.processedPositionalParameterValues;
return copy;
| public java.lang.String | getCacheRegion()
return cacheRegion;
| public java.io.Serializable[] | getCollectionKeys()
return collectionKeys;
| public java.lang.String | getComment()
return comment;
| public org.hibernate.type.Type[] | getFilteredPositionalParameterTypes()
return processedPositionalParameterTypes;
| public java.lang.Object[] | getFilteredPositionalParameterValues()
return processedPositionalParameterValues;
| public java.lang.String | getFilteredSQL()
return processedSQL;
| public java.util.Map | getLockModes()
return lockModes;
| public java.util.Map | getNamedParameters()
return namedParameters;
| public java.lang.String | getOptionalEntityName()
return optionalEntityName;
| public java.io.Serializable | getOptionalId()
return optionalId;
| public java.lang.Object | getOptionalObject()
return optionalObject;
| public org.hibernate.type.Type[] | getPositionalParameterTypes()
return positionalParameterTypes;
| public java.lang.Object[] | getPositionalParameterValues()
return positionalParameterValues;
| public org.hibernate.transform.ResultTransformer | getResultTransformer()
return resultTransformer;
| public RowSelection | getRowSelection()
return rowSelection;
| public org.hibernate.ScrollMode | getScrollMode()
return scrollMode;
| public boolean | hasAutoDiscoverScalarTypes()
return autodiscovertypes;
| public boolean | hasRowSelection()
return rowSelection!=null;
| public boolean | isCacheable()
return cacheable;
| public boolean | isCallable()
return callable;
| public boolean | isNaturalKeyLookup()
return isNaturalKeyLookup;
| public boolean | isReadOnly()
return readOnly;
| public void | processFilters(java.lang.String sql, SessionImplementor session)
if ( session.getEnabledFilters().size()==0 || sql.indexOf(ParserHelper.HQL_VARIABLE_PREFIX)<0 ) {
// HELLA IMPORTANT OPTIMIZATION!!!
processedPositionalParameterValues = getPositionalParameterValues();
processedPositionalParameterTypes = getPositionalParameterTypes();
processedSQL = sql;
}
else {
Dialect dialect = session.getFactory().getDialect();
String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
.append( dialect.openQuote() )
.append( dialect.closeQuote() )
.toString();
StringTokenizer tokens = new StringTokenizer( sql, symbols, true );
StringBuffer result = new StringBuffer();
List parameters = new ArrayList();
List parameterTypes = new ArrayList();
while ( tokens.hasMoreTokens() ) {
final String token = tokens.nextToken();
if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
String filterParameterName = token.substring( 1 );
Object value = session.getFilterParameterValue( filterParameterName );
Type type = session.getFilterParameterType( filterParameterName );
if ( value != null && Collection.class.isAssignableFrom( value.getClass() ) ) {
Iterator itr = ( ( Collection ) value ).iterator();
while ( itr.hasNext() ) {
Object elementValue = itr.next();
result.append( '?" );
parameters.add( elementValue );
parameterTypes.add( type );
if ( itr.hasNext() ) {
result.append( ", " );
}
}
}
else {
result.append( '?" );
parameters.add( value );
parameterTypes.add( type );
}
}
else {
result.append( token );
}
}
parameters.addAll( Arrays.asList( getPositionalParameterValues() ) );
parameterTypes.addAll( Arrays.asList( getPositionalParameterTypes() ) );
processedPositionalParameterValues = parameters.toArray();
processedPositionalParameterTypes = ( Type[] ) parameterTypes.toArray( new Type[0] );
processedSQL = result.toString();
}
| public void | setAutoDiscoverScalarTypes(boolean autodiscovertypes)
this.autodiscovertypes = autodiscovertypes;
| public void | setCacheRegion(java.lang.String cacheRegion)
this.cacheRegion = cacheRegion;
| public void | setCacheable(boolean b)
cacheable = b;
| public void | setCallable(boolean callable)
this.callable = callable;
| public void | setCollectionKeys(java.io.Serializable[] collectionKeys)
this.collectionKeys = collectionKeys;
| public void | setComment(java.lang.String comment)
this.comment = comment;
| public void | setLockModes(java.util.Map map)
lockModes = map;
| public void | setNamedParameters(java.util.Map map)
namedParameters = map;
| public void | setNaturalKeyLookup(boolean isNaturalKeyLookup)
this.isNaturalKeyLookup = isNaturalKeyLookup;
| public void | setOptionalEntityName(java.lang.String optionalEntityName)
this.optionalEntityName = optionalEntityName;
| public void | setOptionalId(java.io.Serializable optionalId)
this.optionalId = optionalId;
| public void | setOptionalObject(java.lang.Object optionalObject)
this.optionalObject = optionalObject;
| public void | setPositionalParameterTypes(org.hibernate.type.Type[] types)
positionalParameterTypes = types;
| public void | setPositionalParameterValues(java.lang.Object[] objects)
positionalParameterValues = objects;
| public void | setReadOnly(boolean readOnly)
this.readOnly = readOnly;
| public void | setRowSelection(RowSelection selection)
rowSelection = selection;
| public void | setScrollMode(org.hibernate.ScrollMode scrollMode)
this.scrollMode = scrollMode;
| public void | traceParameters(SessionFactoryImplementor factory)
Printer print = new Printer(factory);
if (positionalParameterValues.length!=0) {
log.trace(
"parameters: " +
print.toString(positionalParameterTypes, positionalParameterValues)
);
}
if (namedParameters!=null) {
log.trace( "named parameters: " + print.toString(namedParameters) );
}
| public void | validateParameters()
int types = positionalParameterTypes==null ? 0 : positionalParameterTypes.length;
int values = positionalParameterValues==null ? 0 : positionalParameterValues.length;
if (types!=values) {
throw new QueryException(
"Number of positional parameter types:" + types +
" does not match number of positional parameters: " + values
);
}
|
|