Author: steve.ebersole(a)jboss.com
Date: 2009-12-16 19:21:49 -0500 (Wed, 16 Dec 2009)
New Revision: 18253
Added:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/Renderable.java
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImplementor.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java
Log:
HHH-4708 - Make CompoundSelectionImpl implement ExpressionImplementor
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -38,8 +38,6 @@
import javax.persistence.criteria.Subquery;
import javax.persistence.metamodel.EntityType;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
-
/**
* The Hibernate implementation of the JPA {@link CriteriaQuery} contract. Mostly a set
of delegation to its
* internal {@link QueryStructure}.
@@ -342,7 +340,7 @@
String sep = "";
for ( Order orderSpec : getOrderList() ) {
jpaqlQuery.append( sep )
- .append( ( ( ExpressionImplementor ) orderSpec.getExpression() ).render(
renderingContext ) )
+ .append( ( ( Renderable ) orderSpec.getExpression() ).render( renderingContext ) )
.append( orderSpec.isAscending() ? " asc" : " desc" );
sep = ", ";
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -27,19 +27,19 @@
import java.util.Map;
import java.util.Map.Entry;
import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.From;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.MapJoin;
import javax.persistence.criteria.Path;
-import javax.persistence.criteria.From;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type.PersistenceType;
+
import org.hibernate.ejb.criteria.JoinImplementors.JoinImplementor;
import org.hibernate.ejb.criteria.expression.ExpressionImpl;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.type.Type;
@@ -293,7 +293,7 @@
private String path(CriteriaQueryCompiler.RenderingContext renderingContext) {
return origin.getPathIdentifier()
+ '.'
- + ( (ExpressionImplementor) getAttribute() ).renderProjection( renderingContext );
+ + ( (Renderable) getAttribute() ).renderProjection( renderingContext );
}
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -43,8 +43,6 @@
import javax.persistence.criteria.JoinType;
import javax.persistence.metamodel.EntityType;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
-
/**
* Models basic query structure. Used as a delegate in implementing both
* {@link org.hibernate.criterion.CriteriaQuery} and
@@ -214,10 +212,10 @@
if ( getSelection() == null ) {
// we should have only a single root (query validation should have checked this...)
final Root root = getRoots().iterator().next();
- jpaqlQuery.append( ( (ExpressionImplementor) root ).renderProjection(
renderingContext) );
+ jpaqlQuery.append( ( (Renderable) root ).renderProjection( renderingContext) );
}
else {
- jpaqlQuery.append( ( (ExpressionImplementor) getSelection() ).renderProjection(
renderingContext ) );
+ jpaqlQuery.append( ( (Renderable) getSelection() ).renderProjection( renderingContext
) );
}
jpaqlQuery.append( " from " );
@@ -236,7 +234,7 @@
if ( getRestriction() != null) {
jpaqlQuery.append( " where " )
- .append( ( (ExpressionImplementor) getRestriction() ).render( renderingContext ) );
+ .append( ( (Renderable) getRestriction() ).render( renderingContext ) );
}
if ( ! getGroupings().isEmpty() ) {
@@ -244,13 +242,13 @@
sep = "";
for ( Expression grouping : getGroupings() ) {
jpaqlQuery.append( sep )
- .append( ( (ExpressionImplementor) grouping ).render( renderingContext ) );
+ .append( ( (Renderable) grouping ).render( renderingContext ) );
sep = ", ";
}
if ( getHaving() != null ) {
jpaqlQuery.append( " having " )
- .append( ( (ExpressionImplementor) getHaving() ).render( renderingContext ) );
+ .append( ( (Renderable) getHaving() ).render( renderingContext ) );
}
}
}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/Renderable.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/Renderable.java
(rev 0)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/Renderable.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.ejb.criteria;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public interface Renderable {
+ public String render(CriteriaQueryCompiler.RenderingContext renderingContext);
+ public String renderProjection(CriteriaQueryCompiler.RenderingContext
renderingContext);
+}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,6 +28,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models standard arithmetc operations with two operands.
@@ -196,8 +197,8 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
return getOperator().apply(
- ( (ExpressionImplementor) getLeftHandOperand() ).render( renderingContext ),
- ( (ExpressionImplementor) getRightHandOperand() ).render( renderingContext )
+ ( (Renderable) getLeftHandOperand() ).render( renderingContext ),
+ ( (Renderable) getRightHandOperand() ).render( renderingContext )
);
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -30,6 +30,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models an ANSI SQL <tt>COALESCE</tt> expression.
<tt>COALESCE</tt> is a specialized <tt>CASE</tt> statement.
@@ -85,7 +86,7 @@
String sep = "";
for ( Expression expression : getExpressions() ) {
buffer.append( sep )
- .append( ( (ExpressionImplementor) expression ).render( renderingContext ) );
+ .append( ( (Renderable) expression ).render( renderingContext ) );
sep = ", ";
}
return buffer.append( ")" ).toString();
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -24,11 +24,14 @@
package org.hibernate.ejb.criteria.expression;
import java.util.List;
+import javax.persistence.Tuple;
import javax.persistence.criteria.CompoundSelection;
import javax.persistence.criteria.Selection;
+import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
+import org.hibernate.ejb.criteria.Renderable;
/**
* The Hibernate implementation of the JPA {@link CompoundSelection}
@@ -36,7 +39,8 @@
*
* @author Steve Ebersole
*/
-public class CompoundSelectionImpl<X> extends SelectionImpl<X> implements
CompoundSelection<X> {
+public class CompoundSelectionImpl<X> extends SelectionImpl<X> implements
CompoundSelection<X>, Renderable {
+ private final boolean isConstructor;
private List<Selection<?>> selectionItems;
public CompoundSelectionImpl(
@@ -44,6 +48,7 @@
Class<X> javaType,
List<Selection<?>> selectionItems) {
super( criteriaBuilder, javaType );
+ this.isConstructor = !javaType.isArray() && !Tuple.class.isAssignableFrom(
javaType );
this.selectionItems = selectionItems;
}
@@ -63,4 +68,24 @@
}
}
+ public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
+ StringBuilder buff = new StringBuilder();
+ if ( isConstructor ) {
+ buff.append( "new " ).append( getJavaType().getName() ).append( '('
);
+ }
+ String sep = "";
+ for ( Selection selection : selectionItems ) {
+ buff.append( sep )
+ .append( ( (Renderable) selection ).renderProjection( renderingContext ) );
+ sep = ", ";
+ }
+ if ( isConstructor ) {
+ buff.append( ')' );
+ }
+ return buff.toString();
+ }
+
+ public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
+ return render( renderingContext );
+ }
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -27,6 +27,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* A string concatenation.
@@ -78,9 +79,9 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return ( (ExpressionImplementor) getString1() ).render( renderingContext )
+ return ( (Renderable) getString1() ).render( renderingContext )
+ " || "
- + ( (ExpressionImplementor) getString2() ).render( renderingContext );
+ + ( (Renderable) getString2() ).render( renderingContext );
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -35,7 +35,9 @@
*
* @author Steve Ebersole
*/
-public abstract class ExpressionImpl<T> extends SelectionImpl<T> implements
ExpressionImplementor<T> {
+public abstract class ExpressionImpl<T>
+ extends SelectionImpl<T>
+ implements ExpressionImplementor<T> {
public ExpressionImpl(CriteriaBuilderImpl criteriaBuilder, Class<T> javaType) {
super( criteriaBuilder, javaType );
}
@@ -43,6 +45,7 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings({ "unchecked" })
public <X> Expression<X> as(Class<X> type) {
return type.equals( getJavaType() )
? (Expression<X>) this
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImplementor.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImplementor.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImplementor.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -25,14 +25,12 @@
import javax.persistence.criteria.Expression;
-import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
-public interface ExpressionImplementor<T> extends Expression<T> {
- public String render(CriteriaQueryCompiler.RenderingContext renderingContext);
- public String renderProjection(CriteriaQueryCompiler.RenderingContext
renderingContext);
+public interface ExpressionImplementor<T> extends Expression<T>, Renderable
{
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -27,6 +27,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models an ANSI SQL <tt>NULLIF</tt> expression.
<tt>NULLIF</tt> is a specialized <tt>CASE</tt> statement.
@@ -76,9 +77,9 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
return "nullif("
- + ( (ExpressionImplementor) getPrimaryExpression() ).render( renderingContext )
+ + ( (Renderable) getPrimaryExpression() ).render( renderingContext )
+ ','
- + ( (ExpressionImplementor) getSecondaryExpression() ).render( renderingContext )
+ + ( (Renderable) getSecondaryExpression() ).render( renderingContext )
+ ")";
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -30,6 +30,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models what ANSI SQL terms a <tt>searched case expression</tt>. This is a
<tt>CASE</tt> expression
@@ -129,12 +130,12 @@
StringBuilder caseStatement = new StringBuilder( "case" );
for ( WhenClause whenClause : getWhenClauses() ) {
caseStatement.append( " when " )
- .append( ( (ExpressionImplementor) whenClause.getCondition() ).render(
renderingContext ) )
+ .append( ( (Renderable) whenClause.getCondition() ).render( renderingContext ) )
.append( " then " )
- .append( ( (ExpressionImplementor) whenClause.getResult() ).render( renderingContext
) );
+ .append( ( (Renderable) whenClause.getResult() ).render( renderingContext ) );
}
caseStatement.append( " else " )
- .append( ( (ExpressionImplementor) getOtherwiseResult() ).render( renderingContext )
)
+ .append( ( (Renderable) getOtherwiseResult() ).render( renderingContext ) )
.append( " end" );
return caseStatement.toString();
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -30,6 +30,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models what ANSI SQL terms a simple case statement. This is a
<tt>CASE</tt> expression in the form<pre>
@@ -136,15 +137,15 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
StringBuilder caseExpr = new StringBuilder();
caseExpr.append( "case " )
- .append( ( (ExpressionImplementor) getExpression() ).render( renderingContext ) )
+ .append( ( (Renderable) getExpression() ).render( renderingContext ) )
.append( ' ' );
for ( WhenClause whenClause : getWhenClauses() ) {
- caseExpr.append( ( (ExpressionImplementor) whenClause.getCondition() ).render(
renderingContext ) )
+ caseExpr.append( ( (Renderable) whenClause.getCondition() ).render( renderingContext )
)
.append( " then " )
- .append( ( (ExpressionImplementor) whenClause.getResult() ).render( renderingContext
) );
+ .append( ( (Renderable) whenClause.getResult() ).render( renderingContext ) );
}
caseExpr.append( " else " )
- .append( ( (ExpressionImplementor) getOtherwiseResult() ).render( renderingContext )
)
+ .append( ( (Renderable) getOtherwiseResult() ).render( renderingContext ) )
.append( " end" );
return caseExpr.toString();
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -27,6 +27,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Represents a {@link Modifier#ALL}, {@link Modifier#ANY}, {@link Modifier#SOME}
modifier appplied to a subquery as
@@ -80,7 +81,7 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return getModifier().rendered() + ( ( ExpressionImplementor ) getSubquery() ).render(
renderingContext );
+ return getModifier().rendered() + ( (Renderable) getSubquery() ).render(
renderingContext );
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -27,6 +27,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models unary arithmetic operation (unary plus and unary minus).
@@ -74,7 +75,7 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
return ( getOperation() == Operation.UNARY_MINUS ? '-' : '+' )
- + ( (ExpressionImplementor) getOperand() ).render( renderingContext );
+ + ( (Renderable) getOperand() ).render( renderingContext );
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,8 +28,8 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* Models the ANSI SQL <tt>LOCATE</tt> function.
@@ -102,12 +102,12 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
StringBuilder buffer = new StringBuilder();
buffer.append( "locate(" )
- .append( ( (ExpressionImplementor) getPattern() ).render( renderingContext ) )
+ .append( ( (Renderable) getPattern() ).render( renderingContext ) )
.append( ',' )
- .append( ( (ExpressionImplementor) getString() ).render( renderingContext ) );
+ .append( ( (Renderable) getString() ).render( renderingContext ) );
if ( getStart() != null ) {
buffer.append( ',' )
- .append( ( (ExpressionImplementor) getStart() ).render( renderingContext ) );
+ .append( ( (Renderable) getStart() ).render( renderingContext ) );
}
buffer.append( ')' );
return buffer.toString();
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -31,8 +31,8 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* Support for functions with parameters.
@@ -94,7 +94,7 @@
buffer.append( getFunctionName() )
.append( '(' );
for ( Expression argument : argumentExpressions ) {
- buffer.append( ( (ExpressionImplementor) argument ).render( renderingContext ) );
+ buffer.append( ( (Renderable) argument ).render( renderingContext ) );
}
buffer.append( ')' );
return buffer.toString();
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,8 +28,8 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* Models the ANSI SQL <tt>SUBSTRING</tt> function.
@@ -107,12 +107,12 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
StringBuilder buffer = new StringBuilder();
buffer.append( "substring(" )
- .append( ( (ExpressionImplementor) getValue() ).render( renderingContext ) )
+ .append( ( (Renderable) getValue() ).render( renderingContext ) )
.append( ',' )
- .append( ( (ExpressionImplementor) getStart() ).render( renderingContext ) );
+ .append( ( (Renderable) getStart() ).render( renderingContext ) );
if ( getLength() != null ) {
buffer.append( ',' )
- .append( ( (ExpressionImplementor) getLength() ).render( renderingContext ) );
+ .append( ( (Renderable) getLength() ).render( renderingContext ) );
}
buffer.append( ')' );
return buffer.toString();
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,8 +28,8 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* Models the ANSI SQL <tt>TRIM</tt> function.
@@ -118,9 +118,9 @@
.append( "trim(" )
.append( trimspec.name() )
.append( ' ' )
- .append( ( (ExpressionImplementor) trimCharacter ).render( renderingContext ) )
+ .append( ( (Renderable) trimCharacter ).render( renderingContext ) )
.append( " from " )
- .append( ( (ExpressionImplementor) trimSource ).render( renderingContext ) )
+ .append( ( (Renderable) trimSource ).render( renderingContext ) )
.append( ')' )
.toString();
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,7 +28,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models a <tt>BETWEEN</tt> {@link javax.persistence.criteria.Predicate}.
@@ -83,11 +83,11 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return ( (ExpressionImplementor) getExpression() ).render( renderingContext )
+ return ( (Renderable) getExpression() ).render( renderingContext )
+ " between "
- + ( (ExpressionImplementor) getLowerBound() ).render( renderingContext )
+ + ( (Renderable) getLowerBound() ).render( renderingContext )
+ " and "
- + ( (ExpressionImplementor) getUpperBound() ).render( renderingContext );
+ + ( (Renderable) getUpperBound() ).render( renderingContext );
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -29,7 +29,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Defines a {@link Predicate} used to wrap an {@link Expression
Expression<Boolean>}.
@@ -58,7 +58,7 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return ( ( ExpressionImplementor) getExpression() ).render( renderingContext );
+ return ( (Renderable) getExpression() ).render( renderingContext );
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,9 +28,9 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.BinaryOperatorExpression;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* Models a basic relational comparison predicate.
@@ -66,7 +66,9 @@
}
public ComparisonOperator getComparisonOperator() {
- return comparisonOperator;
+ return isNegated()
+ ? comparisonOperator.negated()
+ : comparisonOperator;
}
public Expression getLeftHandOperand() {
@@ -142,9 +144,9 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return ( ( ExpressionImplementor) getLeftHandOperand() ).render( renderingContext )
+ return ( (Renderable) getLeftHandOperand() ).render( renderingContext )
+ getComparisonOperator().rendered()
- + ( ( ExpressionImplementor) getRightHandOperand() ).render( renderingContext );
+ + ( (Renderable) getRightHandOperand() ).render( renderingContext );
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -32,7 +32,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
+import org.hibernate.ejb.criteria.Renderable;
/**
* A compound {@link Predicate predicate} is a grouping of other {@link Predicate
predicates} in order to apply
@@ -113,14 +113,14 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
if ( getExpressions().size() == 1 ) {
- return ( (ExpressionImplementor) getExpressions().get(0) ).render( renderingContext
);
+ return ( (Renderable) getExpressions().get(0) ).render( renderingContext );
}
final StringBuilder buffer = new StringBuilder();
String sep = "";
for ( Expression expression : getExpressions() ) {
buffer.append( sep )
.append( "( " )
- .append( ( (ExpressionImplementor) expression ).render( renderingContext ) )
+ .append( ( (Renderable) expression ).render( renderingContext ) )
.append( " )" );
sep = operatorTextWithSeparator();
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -27,7 +27,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
+import org.hibernate.ejb.criteria.Renderable;
/**
* Models an <tt>EXISTS(<subquery>)</tt> predicate
@@ -52,7 +52,7 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
return ( isNegated() ? "not " : "" ) + "exists "
- + ( ( ExpressionImplementor ) getSubquery() ).render( renderingContext );
+ + ( (Renderable) getSubquery() ).render( renderingContext );
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
{
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,7 +28,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
+import org.hibernate.ejb.criteria.Renderable;
/**
* ANSI-SQL defines <tt>TRUE</tt>, <tt>FALSE</tt> and
<tt>UNKNOWN</tt> as <i>truth values</i>. These
@@ -64,7 +64,7 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return ( (ExpressionImplementor) getBooleanExpression() ).render( renderingContext )
+ return ( (Renderable) getBooleanExpression() ).render( renderingContext )
+ " = "
+ ( getTruthValue() == TruthValue.TRUE ? "true" : "false" );
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -33,8 +33,8 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* TODO : javadoc
@@ -158,14 +158,14 @@
boolean isInSubqueryPredicate = getValues().size() == 1
&& Subquery.class.isInstance( getValues().get( 0 ) );
if ( isInSubqueryPredicate ) {
- buffer.append( ( (ExpressionImplementor) getValues().get(0) ).render( renderingContext
) );
+ buffer.append( ( (Renderable) getValues().get(0) ).render( renderingContext ) );
}
else {
buffer.append( '(' );
String sep = "";
for ( Expression value : getValues() ) {
buffer.append( sep )
- .append( ( (ExpressionImplementor) value ).render( renderingContext ) );
+ .append( ( (Renderable) value ).render( renderingContext ) );
sep = ", ";
}
buffer.append( ')' );
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -27,8 +27,8 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* Models a SQL <tt>LIKE</tt> expression.
@@ -124,12 +124,12 @@
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
StringBuilder likeExpr = new StringBuilder();
- likeExpr.append( ( (ExpressionImplementor) getMatchExpression() ).render(
renderingContext ) )
+ likeExpr.append( ( (Renderable) getMatchExpression() ).render( renderingContext ) )
.append( " like " )
- .append( ( (ExpressionImplementor) getPattern() ).render( renderingContext ) );
+ .append( ( (Renderable) getPattern() ).render( renderingContext ) );
if ( escapeCharacter != null ) {
likeExpr.append( " escape " )
- .append( ( (ExpressionImplementor) getEscapeCharacter() ).render( renderingContext )
);
+ .append( ( (Renderable) getEscapeCharacter() ).render( renderingContext ) );
}
return likeExpr.toString();
}
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java
===================================================================
---
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java 2009-12-16
23:15:01 UTC (rev 18252)
+++
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java 2009-12-17
00:21:49 UTC (rev 18253)
@@ -28,8 +28,8 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.UnaryOperatorExpression;
-import org.hibernate.ejb.criteria.expression.ExpressionImplementor;
/**
* Defines a {@link javax.persistence.criteria.Predicate} for checking the
@@ -65,7 +65,7 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return ( (ExpressionImplementor) operand ).render( renderingContext ) + check();
+ return ( (Renderable) operand ).render( renderingContext ) + check();
}
private String check() {