mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 17:15:02 +00:00
Remove few NotYetImplementedFor6Exception
This commit is contained in:
parent
67f73f20ef
commit
313bc2666c
@ -9,7 +9,6 @@
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.metamodel.MappingMetamodel;
|
import org.hibernate.metamodel.MappingMetamodel;
|
||||||
import org.hibernate.metamodel.mapping.BasicValuedMapping;
|
import org.hibernate.metamodel.mapping.BasicValuedMapping;
|
||||||
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
||||||
@ -22,8 +21,6 @@
|
|||||||
import org.hibernate.query.sqm.tree.SqmVisitableNode;
|
import org.hibernate.query.sqm.tree.SqmVisitableNode;
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmFunction;
|
import org.hibernate.query.sqm.tree.expression.SqmFunction;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
@ -135,15 +132,4 @@ protected MappingModelExpressable<?> getMappingModelExpressable(
|
|||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<T> createDomainResult(
|
|
||||||
String resultVariable,
|
|
||||||
DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
//implemented on SelfRenderingFunctionSqlAstExpression
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
import org.hibernate.boot.model.process.internal.InferredBasicValueResolver;
|
import org.hibernate.boot.model.process.internal.InferredBasicValueResolver;
|
||||||
import org.hibernate.dialect.function.TimestampaddFunction;
|
import org.hibernate.dialect.function.TimestampaddFunction;
|
||||||
import org.hibernate.dialect.function.TimestampdiffFunction;
|
import org.hibernate.dialect.function.TimestampdiffFunction;
|
||||||
import org.hibernate.engine.FetchStyle;
|
|
||||||
import org.hibernate.engine.FetchTiming;
|
import org.hibernate.engine.FetchTiming;
|
||||||
import org.hibernate.engine.profile.FetchProfile;
|
import org.hibernate.engine.profile.FetchProfile;
|
||||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||||
@ -3043,7 +3042,6 @@ else if ( modelPart instanceof EntityMappingType ) {
|
|||||||
|
|
||||||
final Expression result;
|
final Expression result;
|
||||||
if ( resultPart instanceof EntityValuedModelPart ) {
|
if ( resultPart instanceof EntityValuedModelPart ) {
|
||||||
final EntityValuedModelPart mapping = (EntityValuedModelPart) resultPart;
|
|
||||||
final boolean expandToAllColumns;
|
final boolean expandToAllColumns;
|
||||||
if ( currentClauseStack.getCurrent() == Clause.GROUP ) {
|
if ( currentClauseStack.getCurrent() == Clause.GROUP ) {
|
||||||
// When the table group is known to be fetched i.e. a fetch join
|
// When the table group is known to be fetched i.e. a fetch join
|
||||||
@ -3054,11 +3052,23 @@ else if ( modelPart instanceof EntityMappingType ) {
|
|||||||
else {
|
else {
|
||||||
expandToAllColumns = false;
|
expandToAllColumns = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final EntityValuedModelPart mapping = (EntityValuedModelPart) resultPart;
|
||||||
|
EntityMappingType mappingType;
|
||||||
|
if ( path instanceof SqmTreatedPath ) {
|
||||||
|
mappingType = creationContext.getDomainModel()
|
||||||
|
.findEntityDescriptor( ( (SqmTreatedPath) path ).getTreatTarget().getHibernateEntityName() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mappingType = mapping.getEntityMappingType();
|
||||||
|
}
|
||||||
|
|
||||||
final TableGroup parentGroupToUse = findTableGroup( navigablePath.getParent() );
|
final TableGroup parentGroupToUse = findTableGroup( navigablePath.getParent() );
|
||||||
result = EntityValuedPathInterpretation.from(
|
result = EntityValuedPathInterpretation.from(
|
||||||
navigablePath,
|
navigablePath,
|
||||||
parentGroupToUse == null ? tableGroup : parentGroupToUse,
|
parentGroupToUse == null ? tableGroup : parentGroupToUse,
|
||||||
mapping,
|
(EntityValuedModelPart) resultPart,
|
||||||
|
mappingType,
|
||||||
expandToAllColumns,
|
expandToAllColumns,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
@ -3307,6 +3317,28 @@ public Expression visitMinIndexPath(SqmMinIndexPath<?> path) {
|
|||||||
return createMinOrMaxIndexOrElement( path, true, false );
|
return createMinOrMaxIndexOrElement( path, true, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Expression visitCorrelation(SqmCorrelation<?, ?> correlation) {
|
||||||
|
final TableGroup resolved = getFromClauseAccess().findTableGroup( correlation.getNavigablePath() );
|
||||||
|
if ( resolved != null ) {
|
||||||
|
log.tracef( "SqmCorrelation [%s] resolved to existing TableGroup [%s]", correlation, resolved );
|
||||||
|
return visitTableGroup( resolved, correlation );
|
||||||
|
}
|
||||||
|
throw new InterpretationException( "SqmCorrelation not yet resolved to TableGroup" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Expression visitTreatedPath(SqmTreatedPath<?, ?> sqmTreatedPath) {
|
||||||
|
final TableGroup resolved = getFromClauseAccess().findTableGroup( sqmTreatedPath.getNavigablePath() );
|
||||||
|
if ( resolved != null ) {
|
||||||
|
log.tracef( "SqmTreatedPath [%s] resolved to existing TableGroup [%s]", sqmTreatedPath, resolved );
|
||||||
|
return visitTableGroup( resolved, (SqmFrom<?, ?>) sqmTreatedPath );
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InterpretationException( "SqmTreatedPath not yet resolved to TableGroup" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Expression visitPluralAttributeSizeFunction(SqmCollectionSize function) {
|
public Expression visitPluralAttributeSizeFunction(SqmCollectionSize function) {
|
||||||
final SqmPath<?> pluralPath = function.getPluralPath();
|
final SqmPath<?> pluralPath = function.getPluralPath();
|
||||||
@ -3456,7 +3488,7 @@ public DomainResult<Map.Entry<Object, Object>> createDomainResult(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
public void applySqlSelections(DomainResultCreationState creationState) {
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -56,13 +56,21 @@ public static <T> EntityValuedPathInterpretation<T> from(
|
|||||||
.findTableGroup( sqmPath.getLhs().getNavigablePath() )
|
.findTableGroup( sqmPath.getLhs().getNavigablePath() )
|
||||||
.getModelPart()
|
.getModelPart()
|
||||||
.findSubPart( sqmPath.getReferencedPathSource().getPathName(), null );
|
.findSubPart( sqmPath.getReferencedPathSource().getPathName(), null );
|
||||||
return from( sqmPath.getNavigablePath(), tableGroup, mapping, false, sqlAstCreationState );
|
return from(
|
||||||
|
sqmPath.getNavigablePath(),
|
||||||
|
tableGroup,
|
||||||
|
mapping,
|
||||||
|
mapping,
|
||||||
|
false,
|
||||||
|
sqlAstCreationState
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> EntityValuedPathInterpretation<T> from(
|
public static <T> EntityValuedPathInterpretation<T> from(
|
||||||
NavigablePath navigablePath,
|
NavigablePath navigablePath,
|
||||||
TableGroup tableGroup,
|
TableGroup tableGroup,
|
||||||
EntityValuedModelPart mapping,
|
EntityValuedModelPart mapping,
|
||||||
|
EntityValuedModelPart treatedMapping,
|
||||||
boolean expandToAllColumns,
|
boolean expandToAllColumns,
|
||||||
SqmToSqlAstConverter sqlAstCreationState) {
|
SqmToSqlAstConverter sqlAstCreationState) {
|
||||||
final SqlExpressionResolver sqlExprResolver = sqlAstCreationState.getSqlExpressionResolver();
|
final SqlExpressionResolver sqlExprResolver = sqlAstCreationState.getSqlExpressionResolver();
|
||||||
@ -211,7 +219,7 @@ else if ( mapping instanceof EntityAssociationMapping ) {
|
|||||||
sqlExpression,
|
sqlExpression,
|
||||||
navigablePath,
|
navigablePath,
|
||||||
tableGroup,
|
tableGroup,
|
||||||
mapping
|
treatedMapping
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,25 +8,21 @@
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||||
import org.hibernate.query.sqm.SqmPathSource;
|
import org.hibernate.query.sqm.SqmPathSource;
|
||||||
import org.hibernate.query.sqm.spi.SqmCreationHelper;
|
import org.hibernate.query.sqm.spi.SqmCreationHelper;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.query.sqm.tree.SqmJoinType;
|
import org.hibernate.query.sqm.tree.SqmJoinType;
|
||||||
import org.hibernate.query.sqm.tree.from.SqmFrom;
|
import org.hibernate.query.sqm.tree.from.SqmFrom;
|
||||||
import org.hibernate.query.sqm.tree.from.SqmQualifiedJoin;
|
import org.hibernate.query.sqm.tree.from.SqmQualifiedJoin;
|
||||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Beikov
|
* @author Christian Beikov
|
||||||
*/
|
*/
|
||||||
public class SqmPluralPartJoin<O,T> extends AbstractSqmJoin<O,T> implements DomainResultProducer<T>, SqmQualifiedJoin<O, T> {
|
public class SqmPluralPartJoin<O,T> extends AbstractSqmJoin<O,T> implements SqmQualifiedJoin<O, T> {
|
||||||
|
|
||||||
public SqmPluralPartJoin(
|
public SqmPluralPartJoin(
|
||||||
SqmFrom<?,O> lhs,
|
SqmFrom<?,O> lhs,
|
||||||
@ -114,15 +110,4 @@ public String toString() {
|
|||||||
getReferencedPathSource().getPathName()
|
getReferencedPathSource().getPathName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<T> createDomainResult(
|
|
||||||
String resultVariable, DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,12 @@
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.query.criteria.JpaSearchedCase;
|
import org.hibernate.query.criteria.JpaSearchedCase;
|
||||||
import org.hibernate.query.internal.QueryHelper;
|
import org.hibernate.query.internal.QueryHelper;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||||
import org.hibernate.query.sqm.SqmExpressable;
|
import org.hibernate.query.sqm.SqmExpressable;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
import org.hibernate.query.sqm.tree.predicate.SqmPredicate;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
|
|
||||||
import jakarta.persistence.criteria.Expression;
|
import jakarta.persistence.criteria.Expression;
|
||||||
|
|
||||||
@ -27,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
public class SqmCaseSearched<R>
|
public class SqmCaseSearched<R>
|
||||||
extends AbstractSqmExpression<R>
|
extends AbstractSqmExpression<R>
|
||||||
implements JpaSearchedCase<R>, DomainResultProducer<R> {
|
implements JpaSearchedCase<R> {
|
||||||
private final List<WhenFragment<R>> whenFragments;
|
private final List<WhenFragment<R>> whenFragments;
|
||||||
private SqmExpression<R> otherwise;
|
private SqmExpression<R> otherwise;
|
||||||
|
|
||||||
@ -103,18 +99,6 @@ public String asLoggableText() {
|
|||||||
return "<searched-case>";
|
return "<searched-case>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<R> createDomainResult(
|
|
||||||
String resultVariable,
|
|
||||||
DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class WhenFragment<R> {
|
public static class WhenFragment<R> {
|
||||||
private final SqmPredicate predicate;
|
private final SqmPredicate predicate;
|
||||||
private final SqmExpression<R> result;
|
private final SqmExpression<R> result;
|
||||||
|
@ -6,15 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.query.sqm.tree.expression;
|
package org.hibernate.query.sqm.tree.expression;
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||||
import org.hibernate.query.sqm.SqmExpressable;
|
import org.hibernate.query.sqm.SqmExpressable;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the {@code SIZE()} function.
|
* Represents the {@code SIZE()} function.
|
||||||
@ -22,7 +17,7 @@
|
|||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
* @author Gunnar Morling
|
* @author Gunnar Morling
|
||||||
*/
|
*/
|
||||||
public class SqmCollectionSize extends AbstractSqmExpression<Integer> implements DomainResultProducer<Integer> {
|
public class SqmCollectionSize extends AbstractSqmExpression<Integer> {
|
||||||
private final SqmPath<?> pluralPath;
|
private final SqmPath<?> pluralPath;
|
||||||
|
|
||||||
public SqmCollectionSize(SqmPath<?> pluralPath, NodeBuilder nodeBuilder) {
|
public SqmCollectionSize(SqmPath<?> pluralPath, NodeBuilder nodeBuilder) {
|
||||||
@ -55,15 +50,4 @@ public void appendHqlString(StringBuilder sb) {
|
|||||||
sb.append( ')' );
|
sb.append( ')' );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<Integer> createDomainResult(
|
|
||||||
String resultVariable,
|
|
||||||
DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
import org.hibernate.query.sqm.SqmExpressable;
|
import org.hibernate.query.sqm.SqmExpressable;
|
||||||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
||||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||||
@ -28,7 +27,7 @@
|
|||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public abstract class SqmFunction<T> extends AbstractSqmExpression<T>
|
public abstract class SqmFunction<T> extends AbstractSqmExpression<T>
|
||||||
implements JpaFunction<T>, DomainResultProducer<T>, SemanticPathPart {
|
implements JpaFunction<T>, SemanticPathPart {
|
||||||
// this function-name is the one used to resolve the descriptor from
|
// this function-name is the one used to resolve the descriptor from
|
||||||
// the function registry (which may or may not be a db function name)
|
// the function registry (which may or may not be a db function name)
|
||||||
private final String functionName;
|
private final String functionName;
|
||||||
|
@ -6,14 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.query.sqm.tree.expression;
|
package org.hibernate.query.sqm.tree.expression;
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.query.internal.QueryLiteralHelper;
|
import org.hibernate.query.internal.QueryLiteralHelper;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||||
import org.hibernate.query.sqm.SqmExpressable;
|
import org.hibernate.query.sqm.SqmExpressable;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,9 +22,7 @@
|
|||||||
* </ul>
|
* </ul>
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class SqmLiteral<T>
|
public class SqmLiteral<T> extends AbstractSqmExpression<T> {
|
||||||
extends AbstractSqmExpression<T>
|
|
||||||
implements DomainResultProducer<T> {
|
|
||||||
private final T value;
|
private final T value;
|
||||||
|
|
||||||
public SqmLiteral(T value, SqmExpressable<T> inherentType, NodeBuilder nodeBuilder) {
|
public SqmLiteral(T value, SqmExpressable<T> inherentType, NodeBuilder nodeBuilder) {
|
||||||
@ -71,16 +65,4 @@ public static <T> void appendHqlString(StringBuilder sb, JavaType<T> javaTypeDes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<T> createDomainResult(
|
|
||||||
String resultVariable,
|
|
||||||
DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,26 +10,22 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
|
||||||
import org.hibernate.query.NavigablePath;
|
import org.hibernate.query.NavigablePath;
|
||||||
import org.hibernate.query.PathException;
|
import org.hibernate.query.PathException;
|
||||||
import org.hibernate.query.criteria.JpaRoot;
|
import org.hibernate.query.criteria.JpaRoot;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||||
import org.hibernate.query.sqm.SqmPathSource;
|
import org.hibernate.query.sqm.SqmPathSource;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.query.sqm.tree.SqmJoinType;
|
import org.hibernate.query.sqm.tree.SqmJoinType;
|
||||||
import org.hibernate.query.sqm.tree.domain.AbstractSqmFrom;
|
import org.hibernate.query.sqm.tree.domain.AbstractSqmFrom;
|
||||||
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedRoot;
|
import org.hibernate.query.sqm.tree.domain.SqmCorrelatedRoot;
|
||||||
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
import org.hibernate.query.sqm.tree.domain.SqmPath;
|
||||||
import org.hibernate.query.sqm.tree.domain.SqmTreatedRoot;
|
import org.hibernate.query.sqm.tree.domain.SqmTreatedRoot;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E>, DomainResultProducer<E> {
|
public class SqmRoot<E> extends AbstractSqmFrom<E,E> implements JpaRoot<E> {
|
||||||
|
|
||||||
private final boolean allowJoins;
|
private final boolean allowJoins;
|
||||||
private List<SqmJoin<?, ?>> orderedJoins;
|
private List<SqmJoin<?, ?>> orderedJoins;
|
||||||
@ -180,35 +176,4 @@ public <S extends E> SqmFrom<?, S> treatAs(EntityDomainType<S> treatTarget, Stri
|
|||||||
throw new UnsupportedOperationException( "Root treats can not be aliased" );
|
throw new UnsupportedOperationException( "Root treats can not be aliased" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<E> createDomainResult(
|
|
||||||
String resultVariable,
|
|
||||||
DomainResultCreationState creationState) {
|
|
||||||
final String entityName = getReferencedPathSource().getHibernateEntityName();
|
|
||||||
final EntityPersister entityDescriptor = creationState.getSqlAstCreationState()
|
|
||||||
.getCreationContext()
|
|
||||||
.getDomainModel()
|
|
||||||
.getEntityDescriptor( entityName );
|
|
||||||
return entityDescriptor.createDomainResult(
|
|
||||||
getNavigablePath(),
|
|
||||||
creationState.getSqlAstCreationState().getFromClauseAccess().findTableGroup( getNavigablePath() ),
|
|
||||||
resultVariable,
|
|
||||||
creationState
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
final String entityName = getReferencedPathSource().getHibernateEntityName();
|
|
||||||
final EntityPersister entityDescriptor = creationState.getSqlAstCreationState()
|
|
||||||
.getCreationContext()
|
|
||||||
.getDomainModel()
|
|
||||||
.getEntityDescriptor( entityName );
|
|
||||||
entityDescriptor.applySqlSelections(
|
|
||||||
getNavigablePath(),
|
|
||||||
creationState.getSqlAstCreationState().getFromClauseAccess().findTableGroup( getNavigablePath() ),
|
|
||||||
creationState
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,12 @@
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.query.DynamicInstantiationNature;
|
import org.hibernate.query.DynamicInstantiationNature;
|
||||||
import org.hibernate.query.criteria.JpaCompoundSelection;
|
import org.hibernate.query.criteria.JpaCompoundSelection;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
import org.hibernate.query.sqm.tree.expression.SqmExpression;
|
||||||
import org.hibernate.query.sqm.tree.jpa.AbstractJpaSelection;
|
import org.hibernate.query.sqm.tree.jpa.AbstractJpaSelection;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
@ -38,8 +34,7 @@ public class SqmDynamicInstantiation<T>
|
|||||||
extends AbstractJpaSelection<T>
|
extends AbstractJpaSelection<T>
|
||||||
implements SqmSelectableNode<T>,
|
implements SqmSelectableNode<T>,
|
||||||
SqmAliasedExpressionContainer<SqmDynamicInstantiationArgument<?>>,
|
SqmAliasedExpressionContainer<SqmDynamicInstantiationArgument<?>>,
|
||||||
JpaCompoundSelection<T>,
|
JpaCompoundSelection<T> {
|
||||||
DomainResultProducer<T> {
|
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger( SqmDynamicInstantiation.class );
|
private static final Logger log = Logger.getLogger( SqmDynamicInstantiation.class );
|
||||||
|
|
||||||
@ -200,18 +195,6 @@ public SqmDynamicInstantiation<T> makeShallowCopy() {
|
|||||||
return new SqmDynamicInstantiation<>( getInstantiationTarget(), nodeBuilder() );
|
return new SqmDynamicInstantiation<>( getInstantiationTarget(), nodeBuilder() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<T> createDomainResult(
|
|
||||||
String resultVariable,
|
|
||||||
DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DynamicInstantiationTargetImpl<T> implements SqmDynamicInstantiationTarget<T> {
|
private static class DynamicInstantiationTargetImpl<T> implements SqmDynamicInstantiationTarget<T> {
|
||||||
private final DynamicInstantiationNature nature;
|
private final DynamicInstantiationNature nature;
|
||||||
private final JavaType<T> javaTypeDescriptor;
|
private final JavaType<T> javaTypeDescriptor;
|
||||||
|
@ -9,20 +9,16 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import jakarta.persistence.criteria.Selection;
|
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.query.criteria.JpaCompoundSelection;
|
import org.hibernate.query.criteria.JpaCompoundSelection;
|
||||||
import org.hibernate.query.criteria.JpaSelection;
|
import org.hibernate.query.criteria.JpaSelection;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.query.sqm.SqmExpressable;
|
|
||||||
import org.hibernate.query.sqm.SemanticQueryWalker;
|
import org.hibernate.query.sqm.SemanticQueryWalker;
|
||||||
|
import org.hibernate.query.sqm.SqmExpressable;
|
||||||
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
|
import org.hibernate.query.sqm.tree.expression.AbstractSqmExpression;
|
||||||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
|
||||||
import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
|
|
||||||
|
import jakarta.persistence.criteria.Selection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @asciidoctor
|
* @asciidoctor
|
||||||
*
|
*
|
||||||
@ -41,7 +37,7 @@
|
|||||||
*/
|
*/
|
||||||
public class SqmJpaCompoundSelection<T>
|
public class SqmJpaCompoundSelection<T>
|
||||||
extends AbstractSqmExpression<T>
|
extends AbstractSqmExpression<T>
|
||||||
implements JpaCompoundSelection<T>, SqmExpressable<T>, DomainResultProducer<T> {
|
implements JpaCompoundSelection<T>, SqmExpressable<T> {
|
||||||
|
|
||||||
// todo (6.0) : should this really be SqmExpressable?
|
// todo (6.0) : should this really be SqmExpressable?
|
||||||
// - seems like it ought to be limited to just `SqmSelectableNode`.
|
// - seems like it ought to be limited to just `SqmSelectableNode`.
|
||||||
@ -127,15 +123,4 @@ public void visitSubSelectableNodes(Consumer<SqmSelectableNode<?>> jpaSelectionC
|
|||||||
selectableNodes.forEach( jpaSelectionConsumer );
|
selectableNodes.forEach( jpaSelectionConsumer );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DomainResult<T> createDomainResult(
|
|
||||||
String resultVariable,
|
|
||||||
DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applySqlSelections(DomainResultCreationState creationState) {
|
|
||||||
throw new NotYetImplementedFor6Exception( getClass() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.hamcrest.core.Is.is;
|
||||||
|
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +50,7 @@ public void setUp(){
|
|||||||
Price price = new Price( 10, "EUR" );
|
Price price = new Price( 10, "EUR" );
|
||||||
Author author = new Author( "Andrea Camilleri" );
|
Author author = new Author( "Andrea Camilleri" );
|
||||||
Book book = new Book( author, "Il nipote del Negus", price );
|
Book book = new Book( author, "Il nipote del Negus", price );
|
||||||
|
book.setDescription( "is a book" );
|
||||||
Bid bid = new Bid( book );
|
Bid bid = new Bid( book );
|
||||||
entityManager.persist( bid );
|
entityManager.persist( bid );
|
||||||
|
|
||||||
@ -130,7 +133,7 @@ public void testTreatedJoinInWhereClause() {
|
|||||||
assertThat(resultList.size(),is(1));
|
assertThat(resultList.size(),is(1));
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-10561")
|
@TestForIssue(jiraKey = "HHH-10561")
|
||||||
public void testJoinOnTreatedRoot() {
|
public void testJoinOnTreatedRoot() {
|
||||||
@ -143,7 +146,10 @@ public void testJoinOnTreatedRoot() {
|
|||||||
cb.equal(
|
cb.equal(
|
||||||
treatedRoot.<Book, Author>join("author").<String>get("name"),
|
treatedRoot.<Book, Author>join("author").<String>get("name"),
|
||||||
"Andrea Camilleri"));
|
"Andrea Camilleri"));
|
||||||
entityManager.createQuery(criteria.select(treatedRoot)).getResultList();
|
final List<Item> resultList = entityManager.createQuery( criteria.select( treatedRoot ) ).getResultList();
|
||||||
|
final Item item = resultList.get( 0 );
|
||||||
|
assertThat( item, instanceOf(Book.class) );
|
||||||
|
assertEquals( "is a book", item.getDescription() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +169,7 @@ public void testJoinOnTreatedRootWithJoin() {
|
|||||||
entityManager.createQuery(criteria.select(treatedRoot)).getResultList();
|
entityManager.createQuery(criteria.select(treatedRoot)).getResultList();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-10767")
|
@TestForIssue(jiraKey = "HHH-10767")
|
||||||
public void testJoinOnTreatedJoin() {
|
public void testJoinOnTreatedJoin() {
|
||||||
@ -186,6 +192,8 @@ public static class Item {
|
|||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
|
@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
|
||||||
private Price price;
|
private Price price;
|
||||||
|
|
||||||
@ -195,6 +203,14 @@ public Item() {
|
|||||||
public Item(Price price) {
|
public Item(Price price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "Price")
|
@Entity(name = "Price")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user