Revert "HHH-13016 Bring back CaseLiteralExpression"
This reverts commit 23153d5d55
.
This commit is contained in:
parent
23153d5d55
commit
e2ba4105d3
|
@ -1,38 +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.query.criteria.internal.expression;
|
||||
|
||||
import org.hibernate.query.criteria.internal.CriteriaBuilderImpl;
|
||||
import org.hibernate.query.criteria.internal.compile.RenderingContext;
|
||||
import org.hibernate.query.criteria.internal.expression.function.CastFunction;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public class CaseLiteralExpression<T> extends LiteralExpression<T> {
|
||||
|
||||
public CaseLiteralExpression(CriteriaBuilderImpl criteriaBuilder, Class<T> type, T literal) {
|
||||
super( criteriaBuilder, type, literal );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String render(RenderingContext renderingContext) {
|
||||
// There's no need to cast a boolean value and it actually breaks on
|
||||
// MySQL and MariaDB because they don't support casting to bit.
|
||||
// Skip the cast for a boolean literal.
|
||||
if ( getJavaType() == Boolean.class && Boolean.class.isInstance( getLiteral() ) ) {
|
||||
return super.render( renderingContext );
|
||||
}
|
||||
|
||||
// wrapping the result in a cast to determine the node type during the antlr hql parsing phase
|
||||
return CastFunction.CAST_NAME + '(' +
|
||||
super.render( renderingContext ) +
|
||||
" as " +
|
||||
renderingContext.getCastType( getJavaType() ) +
|
||||
')';
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ package org.hibernate.query.criteria.internal.expression;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import javax.persistence.criteria.CriteriaBuilder.Case;
|
||||
import javax.persistence.criteria.Expression;
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class SearchedCaseExpression<R>
|
|||
final Class<R> type = result != null
|
||||
? (Class<R>) result.getClass()
|
||||
: getJavaType();
|
||||
return new CaseLiteralExpression<R>( criteriaBuilder(), type, result );
|
||||
return new LiteralExpression<R>( criteriaBuilder(), type, result );
|
||||
}
|
||||
|
||||
public Case<R> when(Expression<Boolean> condition, Expression<? extends R> result) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SimpleCaseExpression<C,R>
|
|||
final Class<R> type = result != null
|
||||
? (Class<R>) result.getClass()
|
||||
: getJavaType();
|
||||
return new CaseLiteralExpression<R>( criteriaBuilder(), type, result );
|
||||
return new LiteralExpression<R>( criteriaBuilder(), type, result );
|
||||
}
|
||||
|
||||
public SimpleCase<C, R> when(C condition, Expression<? extends R> result) {
|
||||
|
|
Loading…
Reference in New Issue