diff --git a/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlGrammar.java b/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlGrammar.java index 4a1a33151..bfa3f0991 100644 --- a/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlGrammar.java +++ b/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlGrammar.java @@ -193,7 +193,6 @@ public class HqlGrammar extends Grammar{ public static Expr.Comparable year(Expr date){ return createComparable(OpHql.YEAR, date); } - - + } diff --git a/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlOps.java b/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlOps.java index b7a1039da..09ab61e62 100644 --- a/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlOps.java +++ b/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlOps.java @@ -11,14 +11,12 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import com.mysema.query.grammar.Ops; import com.mysema.query.grammar.Ops.Op; -import com.mysema.query.grammar.Ops.OpImpl; +import com.mysema.query.grammar.types.PathMetadata; import com.mysema.query.grammar.types.PathMetadata.PathType; -import com.mysema.query.grammar.types.PathMetadata.PathTypeImpl; /** - * Ops provides + * HqlOps provides * * @author tiwe * @version $Id$ @@ -29,8 +27,8 @@ public class HqlOps { static{ Set> ops = new HashSet>(); - ops.add(Op.IN); - ops.add(Op.NOTIN); + ops.add(Ops.IN); + ops.add(Ops.NOTIN); ops.add(OpQuant.ALL); ops.add(OpQuant.ANY); ops.add(OpQuant.EXISTS); @@ -75,13 +73,13 @@ public class HqlOps { add(OpNumberAgg.MIN, "min(%s)"); // various - add(Op.EQ, "%s = %s",18); - add(Op.ISTYPEOF, "%s.class = %s"); - add(Op.NE, "%s != %s",25); - add(Op.IN, "%s in %s"); - add(Op.NOTIN, "%s not in %s"); - add(Op.ISNULL, "%s is null",26); - add(Op.ISNOTNULL, "%s is not null",26); + add(Ops.EQ, "%s = %s",18); + add(Ops.ISTYPEOF, "%s.class = %s"); + add(Ops.NE, "%s != %s",25); + add(Ops.IN, "%s in %s"); + add(Ops.NOTIN, "%s not in %s"); + add(Ops.ISNULL, "%s is null",26); + add(Ops.ISNOTNULL, "%s is not null",26); // add(Op.SIZE, "size(%s)"); // string @@ -117,12 +115,12 @@ public class HqlOps { add(OpQuant.NOTEXISTS, "not exists %s"); // path types - for (PathType type : new PathType[]{PathType.LISTVALUE, PathType.LISTVALUE_CONSTANT, PathType.MAPVALUE, PathType.MAPVALUE_CONSTANT}){ + for (PathType type : new PathType[]{PathMetadata.LISTVALUE, PathMetadata.LISTVALUE_CONSTANT, PathMetadata.MAPVALUE, PathMetadata.MAPVALUE_CONSTANT}){ add(type,"%s[%s]"); } - add(PathType.PROPERTY,"%s.%s"); // TODO : as string - add(PathType.SIZE,"%s.size"); - add(PathType.VARIABLE,"%s"); // TODO : as string + add(PathMetadata.PROPERTY,"%s.%s"); // TODO : as string + add(PathMetadata.SIZE,"%s.size"); + add(PathMetadata.VARIABLE,"%s"); // TODO : as string // HQL types add(HqlPathType.MINELEMENT, "minelement(%s)"); @@ -155,49 +153,49 @@ public class HqlOps { } public interface OpHql{ - Op CURRENT_DATE = new OpImpl(); - Op CURRENT_TIME = new OpImpl(); - Op CURRENT_TIMESTAMP = new OpImpl(); - Op DAY = new OpImpl(); - Op HOUR = new OpImpl(); - Op ISEMPTY = new OpImpl(); - Op ISNOTEMPTY = new OpImpl(); - Op MINUTE = new OpImpl(); - Op MONTH = new OpImpl(); - Op SECOND = new OpImpl(); - Op SUM = new OpImpl(); - Op SYSDATE = new OpImpl(); - Op YEAR = new OpImpl(); + Op CURRENT_DATE = new Op(); + Op CURRENT_TIME = new Op(); + Op CURRENT_TIMESTAMP = new Op(); + Op DAY = new Op(); + Op HOUR = new Op(); + Op ISEMPTY = new Op(); + Op ISNOTEMPTY = new Op(); + Op MINUTE = new Op(); + Op MONTH = new Op(); + Op SECOND = new Op(); + Op SUM = new Op(); + Op SYSDATE = new Op(); + Op YEAR = new Op(); } public interface OpNumberAgg{ - Op AVG = new OpImpl(); - Op MAX = new OpImpl(); - Op MIN = new OpImpl(); + Op AVG = new Op(); + Op MAX = new Op(); + Op MIN = new Op(); } public interface OpQuant{ - Op AVG_IN_COL = new OpImpl(); - Op MAX_IN_COL = new OpImpl(); - Op MIN_IN_COL = new OpImpl(); + Op AVG_IN_COL = new Op(); + Op MAX_IN_COL = new Op(); + Op MIN_IN_COL = new Op(); // some / any = true for any // all = true for all // exists = true is subselect matches // not exists = true if subselect doesn't match - Op ANY = new OpImpl(); - Op ALL = new OpImpl(); - Op EXISTS = new OpImpl(); - Op NOTEXISTS = new OpImpl(); + Op ANY = new Op(); + Op ALL = new Op(); + Op EXISTS = new Op(); + Op NOTEXISTS = new Op(); } public interface HqlPathType{ - PathType MINELEMENT = new PathTypeImpl(); - PathType MAXELEMENT = new PathTypeImpl(); - PathType MININDEX = new PathTypeImpl(); - PathType MAXINDEX = new PathTypeImpl(); - PathType LISTINDICES = new PathTypeImpl(); - PathType MAPINDICES = new PathTypeImpl(); + PathType MINELEMENT = new PathType(); + PathType MAXELEMENT = new PathType(); + PathType MININDEX = new PathType(); + PathType MAXINDEX = new PathType(); + PathType LISTINDICES = new PathType(); + PathType MAPINDICES = new PathType(); } } diff --git a/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlSerializer.java b/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlSerializer.java index 277a55cab..eedce5064 100644 --- a/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlSerializer.java +++ b/querydsl-hql/src/main/java/com/mysema/query/grammar/HqlSerializer.java @@ -20,6 +20,8 @@ import com.mysema.query.grammar.types.VisitorAdapter; import com.mysema.query.grammar.types.HqlTypes.*; import com.mysema.query.grammar.types.PathMetadata.PathType; +import static com.mysema.query.grammar.types.PathMetadata.*; + /** * HqlSerializer provides @@ -196,8 +198,8 @@ public class HqlSerializer extends VisitorAdapter{ if (path.getMetadata().getParent() != null){ parentAsString = _toString((Expr)path.getMetadata().getParent(),false); } - if (pathType == PathType.PROPERTY || pathType == PathType.VARIABLE || - pathType == PathType.LISTVALUE_CONSTANT){ + if (pathType == PROPERTY || pathType == VARIABLE || + pathType == LISTVALUE_CONSTANT){ exprAsString = path.getMetadata().getExpression().toString(); }else if (path.getMetadata().getExpression() != null){ exprAsString = _toString(path.getMetadata().getExpression(),false); @@ -215,7 +217,7 @@ public class HqlSerializer extends VisitorAdapter{ @Override protected void visit(Path.Collection expr){ // only wrap a PathCollection, if it the pathType is PROPERTY - boolean wrap = wrapElements && expr.getMetadata().getPathType().equals(PathType.PROPERTY); + boolean wrap = wrapElements && expr.getMetadata().getPathType().equals(PROPERTY); if (wrap) _append("elements("); visit((Path)expr); if (wrap) _append(")");