use of org.hibernate.engine.spi.TypedValue in project hibernate-orm by hibernate.
the class DWithinExpression method getTypedValues.
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
final SpatialDialect spatialDialect = ExpressionUtil.getSpatialDialect(criteriaQuery, SpatialFunction.dwithin);
TypedValue typedDistanceValue = new TypedValue(StandardBasicTypes.DOUBLE, distance);
if (spatialDialect instanceof OracleSpatial10gDialect) {
typedDistanceValue = new TypedValue(StandardBasicTypes.STRING, "distance=" + distance);
}
return new TypedValue[] { criteriaQuery.getTypedValue(criteria, propertyName, geometry), typedDistanceValue };
}
use of org.hibernate.engine.spi.TypedValue in project hibernate-orm by hibernate.
the class CriteriaQueryTranslator method getQueryParameters.
public QueryParameters getQueryParameters() {
final RowSelection selection = new RowSelection();
selection.setFirstRow(rootCriteria.getFirstResult());
selection.setMaxRows(rootCriteria.getMaxResults());
selection.setTimeout(rootCriteria.getTimeout());
selection.setFetchSize(rootCriteria.getFetchSize());
final LockOptions lockOptions = new LockOptions();
final Map<String, LockMode> lockModeMap = rootCriteria.getLockModes();
for (final String key : lockModeMap.keySet()) {
final Criteria subcriteria = getAliasedCriteria(key);
lockOptions.setAliasSpecificLockMode(getSQLAlias(subcriteria), lockModeMap.get(key));
}
final List<Object> values = new ArrayList<Object>();
final List<Type> types = new ArrayList<Type>();
final Iterator<CriteriaImpl.Subcriteria> subcriteriaIterator = rootCriteria.iterateSubcriteria();
while (subcriteriaIterator.hasNext()) {
final CriteriaImpl.Subcriteria subcriteria = subcriteriaIterator.next();
final LockMode lm = subcriteria.getLockMode();
if (lm != null) {
lockOptions.setAliasSpecificLockMode(getSQLAlias(subcriteria), lm);
}
if (subcriteria.getWithClause() != null) {
final TypedValue[] tv = subcriteria.getWithClause().getTypedValues(subcriteria, this);
for (TypedValue aTv : tv) {
values.add(aTv.getValue());
types.add(aTv.getType());
}
}
}
// Type and value gathering for the WHERE clause needs to come AFTER lock mode gathering,
// because the lock mode gathering loop now contains join clauses which can contain
// parameter bindings (as in the HQL WITH clause).
final Iterator<CriteriaImpl.CriterionEntry> iter = rootCriteria.iterateExpressionEntries();
while (iter.hasNext()) {
final CriteriaImpl.CriterionEntry ce = iter.next();
final TypedValue[] tv = ce.getCriterion().getTypedValues(ce.getCriteria(), this);
for (TypedValue aTv : tv) {
values.add(aTv.getValue());
types.add(aTv.getType());
}
}
final Object[] valueArray = values.toArray();
final Type[] typeArray = ArrayHelper.toTypeArray(types);
return new QueryParameters(typeArray, valueArray, lockOptions, selection, rootCriteria.isReadOnlyInitialized(), (rootCriteria.isReadOnlyInitialized() && rootCriteria.isReadOnly()), rootCriteria.getCacheable(), rootCriteria.getCacheRegion(), rootCriteria.getComment(), rootCriteria.getQueryHints(), rootCriteria.isLookupByNaturalKey(), rootCriteria.getResultTransformer());
}
use of org.hibernate.engine.spi.TypedValue in project hibernate-orm by hibernate.
the class SimpleSubqueryExpression method getTypedValues.
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
final TypedValue[] subQueryTypedValues = super.getTypedValues(criteria, criteriaQuery);
final TypedValue[] result = new TypedValue[subQueryTypedValues.length + 1];
System.arraycopy(subQueryTypedValues, 0, result, 1, subQueryTypedValues.length);
result[0] = new TypedValue(getTypes()[0], value);
return result;
}
use of org.hibernate.engine.spi.TypedValue in project hibernate-orm by hibernate.
the class InExpression method getTypedValues.
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) {
final ArrayList<TypedValue> list = new ArrayList<TypedValue>();
final Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
if (type.isComponentType()) {
final CompositeType compositeType = (CompositeType) type;
final Type[] subTypes = compositeType.getSubtypes();
for (Object value : values) {
for (int i = 0; i < subTypes.length; i++) {
final Object subValue = value == null ? null : compositeType.getPropertyValues(value, EntityMode.POJO)[i];
list.add(new TypedValue(subTypes[i], subValue));
}
}
} else {
for (Object value : values) {
list.add(criteriaQuery.getTypedValue(criteria, propertyName, value));
}
}
return list.toArray(new TypedValue[list.size()]);
}
use of org.hibernate.engine.spi.TypedValue in project hibernate-orm by hibernate.
the class Example method addPropertyTypedValue.
protected void addPropertyTypedValue(Object value, Type type, List<TypedValue> list) {
if (value != null) {
if (value instanceof String) {
String string = (String) value;
if (isIgnoreCaseEnabled) {
string = string.toLowerCase(Locale.ROOT);
}
if (isLikeEnabled) {
string = matchMode.toMatchString(string);
}
value = string;
}
list.add(new TypedValue(type, value));
}
}
Aggregations