![JAR search and dependency download from the Maven repository](/logo.png)
org.hibernate.cache.QueryKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate Show documentation
Show all versions of hibernate Show documentation
Relational Persistence for Java
//$Id: QueryKey.java 9636 2006-03-16 14:14:48Z [email protected] $
package org.hibernate.cache;
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
import org.hibernate.EntityMode;
import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.RowSelection;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.Type;
import org.hibernate.util.EqualsHelper;
/**
* A key that identifies a particular query with bound parameter values
* @author Gavin King
*/
public class QueryKey implements Serializable {
private final String sqlQueryString;
private final Type[] types;
private final Object[] values;
private final Integer firstRow;
private final Integer maxRows;
private final Map namedParameters;
private final EntityMode entityMode;
private final Set filters;
private final int hashCode;
// the user provided resulttransformer, not the one used with "select new". Here to avoid mangling transformed/non-transformed results.
private final ResultTransformer customTransformer;
public QueryKey(String queryString, QueryParameters queryParameters, Set filters, EntityMode entityMode) {
this.sqlQueryString = queryString;
this.types = queryParameters.getPositionalParameterTypes();
this.values = queryParameters.getPositionalParameterValues();
RowSelection selection = queryParameters.getRowSelection();
if (selection!=null) {
firstRow = selection.getFirstRow();
maxRows = selection.getMaxRows();
}
else {
firstRow = null;
maxRows = null;
}
this.namedParameters = queryParameters.getNamedParameters();
this.entityMode = entityMode;
this.filters = filters;
this.customTransformer = queryParameters.getResultTransformer();
this.hashCode = getHashCode();
}
public boolean equals(Object other) {
QueryKey that = (QueryKey) other;
if ( !sqlQueryString.equals(that.sqlQueryString) ) return false;
if ( !EqualsHelper.equals(firstRow, that.firstRow) || !EqualsHelper.equals(maxRows, that.maxRows) ) return false;
if ( !EqualsHelper.equals(customTransformer, that.customTransformer) ) return false;
if (types==null) {
if (that.types!=null) return false;
}
else {
if (that.types==null) return false;
if ( types.length!=that.types.length ) return false;
for ( int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy