6 - SQM based on JPA type system

This commit is contained in:
Andrea Boriero 2019-07-11 09:58:57 +01:00
parent 398ef8d640
commit 230a819065
4 changed files with 32 additions and 18 deletions

View File

@ -7,8 +7,10 @@
package org.hibernate.metamodel.model.domain;
import org.hibernate.Incubating;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.mapping.spi.Writeable;
import org.hibernate.query.Query;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* Specialization of DomainType for types that can be used as {@link Query} parameter bind values
@ -23,4 +25,8 @@ import org.hibernate.query.Query;
*/
@Incubating
public interface AllowableParameterType<J> extends Writeable {
default JavaTypeDescriptor<J> getExpressableJavaTypeDescriptor(){
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -8,6 +8,7 @@ package org.hibernate.persister.entity;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.QueryException;
import org.hibernate.annotations.Remove;
import org.hibernate.metamodel.model.domain.DomainType;
import org.hibernate.persister.SqlExpressableType;
import org.hibernate.type.Type;
@ -74,4 +75,9 @@ public interface PropertyMapping {
* Given a property path, return the corresponding column name(s).
*/
public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException;
/**
* Get the type of the thing containing the properties
*/
@Remove
public Type getType();
}

View File

@ -71,22 +71,22 @@ public class BinaryArithmeticExpression
walker.visitBinaryArithmeticExpression( this );
}
@Override
public DomainResult createDomainResult(
String resultVariable,
DomainResultCreationState creationState) {
final SqlSelection sqlSelection = creationState.getSqlExpressionResolver().resolveSqlSelection(
this,
getType().getJavaTypeDescriptor(),
creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
);
//noinspection unchecked
return new ScalarDomainResultImpl(
sqlSelection.getValuesArrayPosition(),
resultVariable,
resultType.getJavaTypeDescriptor()
);
}
// @Override
// public DomainResult createDomainResult(
// String resultVariable,
// DomainResultCreationState creationState) {
// final SqlSelection sqlSelection = creationState.getSqlExpressionResolver().resolveSqlSelection(
// this,
// getType().getJavaTypeDescriptor(),
// creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
// );
// //noinspection unchecked
// return new ScalarDomainResultImpl(
// sqlSelection.getValuesArrayPosition(),
// resultVariable,
// resultType.getJavaTypeDescriptor()
// );
// }
/**
* Get the left-hand operand.

View File

@ -19,10 +19,12 @@ public interface DomainResultProducer<T> {
/**
* Produce the domain query
*/
DomainResult<T> createDomainResult(
default DomainResult<T> createDomainResult(
int valuesArrayPosition,
String resultVariable,
DomainResultCreationState creationState);
DomainResultCreationState creationState){
throw new NotYetImplementedFor6Exception( getClass() );
}
/**
* Used when this producer is a selection in a sub-query. The