diff --git a/querydsl-core/src/main/java/com/mysema/query/types/path/CollectionPath.java b/querydsl-core/src/main/java/com/mysema/query/types/path/CollectionPath.java index 946b1908f..112d553a2 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/path/CollectionPath.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/path/CollectionPath.java @@ -16,6 +16,7 @@ import com.mysema.query.types.ExpressionException; import com.mysema.query.types.Path; import com.mysema.query.types.PathImpl; import com.mysema.query.types.PathMetadata; +import com.mysema.query.types.PathMetadataFactory; import com.mysema.query.types.Visitor; import com.mysema.query.types.expr.SimpleExpression; @@ -39,6 +40,10 @@ public class CollectionPath> extends Collection private final Class queryType; + public CollectionPath(Class type, Class queryType, String variable) { + this(type, queryType, PathMetadataFactory.forVariable(variable)); + } + @SuppressWarnings("unchecked") public CollectionPath(Class type, Class queryType, PathMetadata metadata) { super((Class)Collection.class); diff --git a/querydsl-core/src/main/java/com/mysema/query/types/path/ListPath.java b/querydsl-core/src/main/java/com/mysema/query/types/path/ListPath.java index caefc108d..119a7697a 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/path/ListPath.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/path/ListPath.java @@ -46,6 +46,10 @@ public class ListPath> extends CollectionPathBa @Nullable private transient Q any; + public ListPath(Class elementType, Class queryType, String variable) { + this(elementType, queryType, PathMetadataFactory.forVariable(variable)); + } + @SuppressWarnings("unchecked") public ListPath(Class elementType, Class queryType, PathMetadata metadata) { super((Class)List.class); diff --git a/querydsl-core/src/main/java/com/mysema/query/types/path/SetPath.java b/querydsl-core/src/main/java/com/mysema/query/types/path/SetPath.java index 611006adc..b720b17c1 100644 --- a/querydsl-core/src/main/java/com/mysema/query/types/path/SetPath.java +++ b/querydsl-core/src/main/java/com/mysema/query/types/path/SetPath.java @@ -16,6 +16,7 @@ import com.mysema.query.types.ExpressionException; import com.mysema.query.types.Path; import com.mysema.query.types.PathImpl; import com.mysema.query.types.PathMetadata; +import com.mysema.query.types.PathMetadataFactory; import com.mysema.query.types.Visitor; import com.mysema.query.types.expr.SimpleExpression; @@ -39,6 +40,10 @@ public class SetPath> extends CollectionPathBas private final Class queryType; + public SetPath(Class type, Class queryType, String variable) { + this(type, queryType, PathMetadataFactory.forVariable(variable)); + } + @SuppressWarnings("unchecked") public SetPath(Class type, Class queryType, PathMetadata metadata) { super((Class)Set.class); diff --git a/querydsl-core/src/test/java/com/mysema/query/types/path/BeanPathTest.java b/querydsl-core/src/test/java/com/mysema/query/types/path/BeanPathTest.java index ccb99ec73..f439afb72 100644 --- a/querydsl-core/src/test/java/com/mysema/query/types/path/BeanPathTest.java +++ b/querydsl-core/src/test/java/com/mysema/query/types/path/BeanPathTest.java @@ -8,17 +8,22 @@ import com.mysema.query.annotations.PropertyType; public class BeanPathTest { + private BeanPath beanPath = new BeanPath(BeanPathTest.class, "p"); + + @Test + public void As(){ + SimplePath simplePath = new SimplePath(BeanPathTest.class, "p"); + assertNotNull(beanPath.as(simplePath)); + } + @Test public void CreateEnum(){ - BeanPath beanPath = new BeanPath(BeanPathTest.class, "p"); assertNotNull(beanPath.createEnum("property", PropertyType.class)); } @Test - public void As(){ - BeanPath beanPath = new BeanPath(BeanPathTest.class, "p"); - SimplePath simplePath = new SimplePath(BeanPathTest.class, "p"); - assertNotNull(beanPath.as(simplePath)); + public void InstanceOf(){ + assertNotNull(beanPath.instanceOf(BeanPathTest.class)); } } diff --git a/querydsl-core/src/test/java/com/mysema/query/types/path/ListPathTest.java b/querydsl-core/src/test/java/com/mysema/query/types/path/ListPathTest.java index 3ee34d10d..74633c1bc 100644 --- a/querydsl-core/src/test/java/com/mysema/query/types/path/ListPathTest.java +++ b/querydsl-core/src/test/java/com/mysema/query/types/path/ListPathTest.java @@ -1,9 +1,10 @@ package com.mysema.query.types.path; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import org.junit.Test; +import com.mysema.query.types.ConstantImpl; import com.mysema.query.types.PathMetadataFactory; public class ListPathTest { @@ -17,6 +18,8 @@ public class ListPathTest { assertEquals("stringPath", stringPath.any().toString()); assertEquals("eqIc(stringPath.get(0),X)", stringPath.get(0).equalsIgnoreCase("X").toString()); assertEquals("eqIc(stringPath,X)", stringPath.any().equalsIgnoreCase("X").toString()); + assertEquals("stringPath.get(0)", stringPath.get(ConstantImpl.create(0)).toString()); + } } diff --git a/querydsl-core/src/test/java/com/mysema/query/types/path/PathTest.java b/querydsl-core/src/test/java/com/mysema/query/types/path/PathTest.java index 88a7b526a..1239eedc6 100644 --- a/querydsl-core/src/test/java/com/mysema/query/types/path/PathTest.java +++ b/querydsl-core/src/test/java/com/mysema/query/types/path/PathTest.java @@ -144,10 +144,13 @@ public class PathTest { paths.add(new ArrayPath(String[].class, "p")); paths.add(new BeanPath(Object.class, "p")); paths.add(new BooleanPath("p")); + paths.add(new CollectionPath(String.class, StringPath.class, "p")); paths.add(new ComparablePath(String.class,"p")); paths.add(new DatePath(Date.class,"p")); paths.add(new DateTimePath(Date.class,"p")); paths.add(new EnumPath(ExampleEnum.class,"p")); + paths.add(new ListPath(String.class, StringPath.class, "p")); + paths.add(new MapPath(String.class, String.class, StringPath.class, "p")); paths.add(new NumberPath(Integer.class,"p")); paths.add(new SimplePath(String.class,"p")); paths.add(new StringPath("p"));