Joined inheritance work - Removed CasePredicate
This commit is contained in:
parent
fccaca8391
commit
dbd1079828
|
@ -112,7 +112,6 @@ import org.hibernate.sql.ast.tree.from.TableGroup;
|
|||
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
|
||||
import org.hibernate.sql.ast.tree.predicate.BetweenPredicate;
|
||||
import org.hibernate.sql.ast.tree.predicate.CasePredicate;
|
||||
import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate;
|
||||
import org.hibernate.sql.ast.tree.predicate.GroupedPredicate;
|
||||
import org.hibernate.sql.ast.tree.predicate.InListPredicate;
|
||||
|
@ -1372,7 +1371,7 @@ public abstract class BaseSqmToSqlAstConverter
|
|||
|
||||
for ( SqmCaseSearched.WhenFragment whenFragment : expression.getWhenFragments() ) {
|
||||
result.when(
|
||||
(CasePredicate) whenFragment.getPredicate().accept( this ),
|
||||
(Predicate) whenFragment.getPredicate().accept( this ),
|
||||
(Expression) whenFragment.getResult().accept( this )
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import java.util.List;
|
|||
|
||||
import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate;
|
||||
import org.hibernate.sql.ast.tree.predicate.NullnessPredicate;
|
||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
|
@ -28,14 +31,15 @@ public class DecodeCaseExpressionWalker implements CaseExpressionWalker {
|
|||
CaseSearchedExpression.WhenFragment firstWhenFragment = null;
|
||||
for ( int i = 0; i < caseNumber; i++ ) {
|
||||
final CaseSearchedExpression.WhenFragment whenFragment = whenFragments.get( i );
|
||||
Predicate predicate = whenFragment.getPredicate();
|
||||
if ( i != 0 ) {
|
||||
sqlBuffer.append( ", " );
|
||||
whenFragment.getPredicate().getLeftHandExpression().accept( sqlAstWalker );
|
||||
getLeftHandExpression( predicate ).accept( sqlAstWalker );
|
||||
sqlBuffer.append( ", " );
|
||||
whenFragment.getResult().accept( sqlAstWalker );
|
||||
}
|
||||
else {
|
||||
whenFragment.getPredicate().getLeftHandExpression().accept( sqlAstWalker );
|
||||
predicate.getLeftHandExpression().accept( sqlAstWalker );
|
||||
firstWhenFragment = whenFragment;
|
||||
}
|
||||
}
|
||||
|
@ -50,4 +54,12 @@ public class DecodeCaseExpressionWalker implements CaseExpressionWalker {
|
|||
|
||||
sqlBuffer.append( ')' );
|
||||
}
|
||||
|
||||
protected Expression getLeftHandExpression(Predicate predicate) {
|
||||
if ( predicate instanceof NullnessPredicate ) {
|
||||
return ( (NullnessPredicate) predicate ).getExpression();
|
||||
}
|
||||
assert predicate instanceof ComparisonPredicate;
|
||||
return ( (ComparisonPredicate) predicate ).getLeftHandExpression();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
|||
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
|
||||
import org.hibernate.sql.ast.spi.SqlAstWalker;
|
||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||
import org.hibernate.sql.ast.tree.predicate.CasePredicate;
|
||||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||
import org.hibernate.sql.results.internal.SqlSelectionImpl;
|
||||
import org.hibernate.sql.results.internal.domain.basic.BasicResult;
|
||||
import org.hibernate.sql.results.spi.DomainResult;
|
||||
|
@ -44,7 +44,7 @@ public class CaseSearchedExpression implements Expression, DomainResultProducer
|
|||
return otherwise;
|
||||
}
|
||||
|
||||
public void when(CasePredicate predicate, Expression result) {
|
||||
public void when(Predicate predicate, Expression result) {
|
||||
whenFragments.add( new WhenFragment( predicate, result ) );
|
||||
}
|
||||
|
||||
|
@ -58,14 +58,16 @@ public class CaseSearchedExpression implements Expression, DomainResultProducer
|
|||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
|
||||
final SqlSelection sqlSelection = creationState.getSqlAstCreationState().getSqlExpressionResolver().resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressableJavaTypeDescriptor(),
|
||||
creationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
.getTypeConfiguration()
|
||||
);
|
||||
final SqlSelection sqlSelection = creationState.getSqlAstCreationState()
|
||||
.getSqlExpressionResolver()
|
||||
.resolveSqlSelection(
|
||||
this,
|
||||
type.getExpressableJavaTypeDescriptor(),
|
||||
creationState.getSqlAstCreationState()
|
||||
.getCreationContext()
|
||||
.getSessionFactory()
|
||||
.getTypeConfiguration()
|
||||
);
|
||||
|
||||
//noinspection unchecked
|
||||
return new BasicResult(
|
||||
|
@ -100,15 +102,15 @@ public class CaseSearchedExpression implements Expression, DomainResultProducer
|
|||
}
|
||||
|
||||
public static class WhenFragment {
|
||||
private final CasePredicate predicate;
|
||||
private final Predicate predicate;
|
||||
private final Expression result;
|
||||
|
||||
public WhenFragment(CasePredicate predicate, Expression result) {
|
||||
public WhenFragment(Predicate predicate, Expression result) {
|
||||
this.predicate = predicate;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public CasePredicate getPredicate() {
|
||||
public Predicate getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.sql.ast.tree.predicate;
|
||||
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public interface CasePredicate extends Predicate {
|
||||
Expression getLeftHandExpression();
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import org.hibernate.sql.ast.tree.expression.Expression;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ComparisonPredicate implements Predicate, CasePredicate {
|
||||
public class ComparisonPredicate implements Predicate {
|
||||
private final Expression leftHandExpression;
|
||||
private ComparisonOperator operator;
|
||||
private final Expression rightHandExpression;
|
||||
|
@ -27,7 +27,6 @@ public class ComparisonPredicate implements Predicate, CasePredicate {
|
|||
this.rightHandExpression = rightHandExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression getLeftHandExpression() {
|
||||
return leftHandExpression;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.sql.ast.tree.expression.Expression;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class NullnessPredicate implements Predicate, CasePredicate {
|
||||
public class NullnessPredicate implements Predicate {
|
||||
private final Expression expression;
|
||||
private final boolean negated;
|
||||
|
||||
|
@ -38,9 +38,4 @@ public class NullnessPredicate implements Predicate, CasePredicate {
|
|||
public void accept(SqlAstWalker sqlTreeWalker) {
|
||||
sqlTreeWalker.visitNullnessPredicate( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression getLeftHandExpression() {
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue