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; package org.hibernate.metamodel.model.domain;
import org.hibernate.Incubating; import org.hibernate.Incubating;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.mapping.spi.Writeable; import org.hibernate.metamodel.model.mapping.spi.Writeable;
import org.hibernate.query.Query; 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 * 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 @Incubating
public interface AllowableParameterType<J> extends Writeable { 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.NotYetImplementedFor6Exception;
import org.hibernate.QueryException; import org.hibernate.QueryException;
import org.hibernate.annotations.Remove;
import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.metamodel.model.domain.DomainType;
import org.hibernate.persister.SqlExpressableType; import org.hibernate.persister.SqlExpressableType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
@ -74,4 +75,9 @@ public interface PropertyMapping {
* Given a property path, return the corresponding column name(s). * Given a property path, return the corresponding column name(s).
*/ */
public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException; 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 ); walker.visitBinaryArithmeticExpression( this );
} }
@Override // @Override
public DomainResult createDomainResult( // public DomainResult createDomainResult(
String resultVariable, // String resultVariable,
DomainResultCreationState creationState) { // DomainResultCreationState creationState) {
final SqlSelection sqlSelection = creationState.getSqlExpressionResolver().resolveSqlSelection( // final SqlSelection sqlSelection = creationState.getSqlExpressionResolver().resolveSqlSelection(
this, // this,
getType().getJavaTypeDescriptor(), // getType().getJavaTypeDescriptor(),
creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration() // creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
); // );
//noinspection unchecked // //noinspection unchecked
return new ScalarDomainResultImpl( // return new ScalarDomainResultImpl(
sqlSelection.getValuesArrayPosition(), // sqlSelection.getValuesArrayPosition(),
resultVariable, // resultVariable,
resultType.getJavaTypeDescriptor() // resultType.getJavaTypeDescriptor()
); // );
} // }
/** /**
* Get the left-hand operand. * Get the left-hand operand.

View File

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