mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Merge branch 'master' of github.com:mysema/querydsl
This commit is contained in:
commit
8582db0613
@ -3,6 +3,8 @@ package com.mysema.query.domain;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
@ -13,6 +15,8 @@ import javax.persistence.OneToMany;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.types.expr.BooleanExpression;
|
||||
|
||||
public class AnyUsageTest {
|
||||
|
||||
@Entity
|
||||
@ -59,5 +63,23 @@ public class AnyUsageTest {
|
||||
assertNotNull(dealer);
|
||||
assertNotNull(dealer.company);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void WithQDealer() {
|
||||
List<Company> companies = new LinkedList<Company>();
|
||||
companies.add( new Company() );
|
||||
QAnyUsageTest_Dealer qDealer = QAnyUsageTest_Dealer.dealer;
|
||||
BooleanExpression expression = qDealer.company.in( companies );
|
||||
assertNotNull(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void WithQDealerGroup() {
|
||||
List<Company> companies = new LinkedList<Company>();
|
||||
companies.add( new Company() );
|
||||
QAnyUsageTest_Dealer qDealer = QAnyUsageTest_DealerGroup.dealerGroup.dealers.any();
|
||||
BooleanExpression expression = qDealer.company.in( companies );
|
||||
assertNotNull(expression);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
package com.mysema.query.domain;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.annotations.QueryEntity;
|
||||
import com.mysema.query.types.path.ArrayPath;
|
||||
import com.mysema.query.types.path.ListPath;
|
||||
import com.mysema.query.types.path.MapPath;
|
||||
import com.mysema.query.types.path.StringPath;
|
||||
|
||||
public class ArrayExtTest {
|
||||
|
||||
private static final QArrayExtTest_BinaryFile binaryFile = QArrayExtTest_BinaryFile.binaryFile;
|
||||
|
||||
@QueryEntity
|
||||
public class BinaryFile {
|
||||
|
||||
byte[] contentPart;
|
||||
|
||||
List<byte[]> list;
|
||||
|
||||
Map<String, byte[]> map1;
|
||||
|
||||
Map<byte[], String> map2;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void BinaryFile_contentPart() {
|
||||
assertEquals(ArrayPath.class, binaryFile.contentPart.getClass());
|
||||
assertEquals(Byte[].class, binaryFile.contentPart.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void BinaryFile_list() {
|
||||
assertEquals(ListPath.class, binaryFile.list.getClass());
|
||||
assertEquals(List.class, binaryFile.list.getType());
|
||||
assertEquals(Byte[].class, binaryFile.list.getParameter(0));
|
||||
|
||||
assertEquals(ArrayPath.class, binaryFile.list.get(0).getClass());
|
||||
assertEquals(Byte[].class, binaryFile.list.get(0).getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void BinaryFile_map1() {
|
||||
assertEquals(MapPath.class, binaryFile.map1.getClass());
|
||||
assertEquals(Map.class, binaryFile.map1.getType());
|
||||
assertEquals(String.class, binaryFile.map1.getParameter(0));
|
||||
assertEquals(Byte[].class, binaryFile.map1.getParameter(1));
|
||||
|
||||
assertEquals(ArrayPath.class, binaryFile.map1.get("").getClass());
|
||||
assertEquals(Byte[].class, binaryFile.map1.get("").getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void BinaryFile_map2() {
|
||||
assertEquals(MapPath.class, binaryFile.map2.getClass());
|
||||
assertEquals(Map.class, binaryFile.map2.getType());
|
||||
assertEquals(Byte[].class, binaryFile.map2.getParameter(0));
|
||||
assertEquals(String.class, binaryFile.map2.getParameter(1));
|
||||
|
||||
assertEquals(StringPath.class, binaryFile.map2.get(new Byte[0]).getClass());
|
||||
assertEquals(String.class, binaryFile.map2.get(new Byte[0]).getType());
|
||||
}
|
||||
|
||||
}
|
||||
@ -149,7 +149,7 @@ public class RelationTest extends AbstractTest{
|
||||
public void List_Usage(){
|
||||
String expected = "relationType.list.get(0).set";
|
||||
assertEquals(expected, QRelationTest_RelationType.relationType.list.get(0).set.toString());
|
||||
assertEquals(expected, QRelationTest_RelationType.relationType.getList(0).set.toString());
|
||||
// assertEquals(expected, QRelationTest_RelationType.relationType.getList(0).set.toString());
|
||||
|
||||
assertEquals(List.class, QRelationTest_RelationType.relationType.list.getType());
|
||||
assertEquals(Set.class, QRelationTest_RelationType.relationType.set.getType());
|
||||
|
||||
@ -117,7 +117,11 @@ public final class TypeMappings {
|
||||
|
||||
private Type getQueryType(Map<TypeCategory, Type> types, Type type, EntityType model, boolean raw, boolean rawParameters, boolean extend){
|
||||
Type exprType = types.get(type.getCategory());
|
||||
return getQueryType(type, model, exprType, raw, rawParameters, extend);
|
||||
if (type.getCategory() == TypeCategory.ARRAY && types == pathTypes) {
|
||||
return getQueryType(type.getComponentType(), model, exprType, raw, rawParameters, extend);
|
||||
} else {
|
||||
return getQueryType(type, model, exprType, raw, rawParameters, extend);
|
||||
}
|
||||
}
|
||||
|
||||
public Type getQueryType(Type type, EntityType model, Type exprType, boolean raw, boolean rawParameters, boolean extend){
|
||||
|
||||
@ -12,6 +12,7 @@ import java.util.Set;
|
||||
final class Constants {
|
||||
|
||||
private static final Set<Class<?>> typedClasses = new HashSet<Class<?>>(Arrays.<Class<?>>asList(
|
||||
ArrayPath.class,
|
||||
PathBuilder.class,
|
||||
ComparablePath.class,
|
||||
EnumPath.class,
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
<commons.collections.version>4.01</commons.collections.version>
|
||||
<commons.lang.version>2.4</commons.lang.version>
|
||||
<codegen.version>0.4.1</codegen.version>
|
||||
<codegen.version>0.4.2</codegen.version>
|
||||
<mysema.lang.version>0.2.1</mysema.lang.version>
|
||||
<cglib.version>2.2</cglib.version>
|
||||
<findbugs.version>1.3.2</findbugs.version>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user