mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
This commit is contained in:
parent
af7df11b69
commit
3933894e08
@ -1,9 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Mysema Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
package com.mysema.query.grammar.types;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Projection provides
|
||||
@ -13,6 +20,8 @@ import java.lang.reflect.ParameterizedType;
|
||||
*/
|
||||
public class Projection extends Path.PEntity<Object>{
|
||||
|
||||
private Set<String> fields = new HashSet<String>();
|
||||
|
||||
private String entityName;
|
||||
|
||||
private static Method _numberMethod, _comparableMethod;
|
||||
@ -37,6 +46,7 @@ public class Projection extends Path.PEntity<Object>{
|
||||
for (Field field : cl.getDeclaredFields()){
|
||||
if (Expr.class.isAssignableFrom(field.getType()) && field.getGenericType() instanceof ParameterizedType){
|
||||
field.setAccessible(true);
|
||||
fields.add(field.getName());
|
||||
handleField(field);
|
||||
}
|
||||
}
|
||||
@ -71,4 +81,8 @@ public class Projection extends Path.PEntity<Object>{
|
||||
return entityName;
|
||||
}
|
||||
|
||||
public void accept(SubQuery<?,?> query){
|
||||
// TODO : validate that the given SubQuery can be projected
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,11 +38,15 @@ public class SubQuery<JM,A> extends Expr<A> implements Query<SubQuery<JM,A>>, Co
|
||||
public SubQuery<JM,A> join(EEntity<?> o) {query.join(o); return this;}
|
||||
public SubQuery<JM,A> leftJoin(EEntity<?> o) {query.leftJoin(o); return this;}
|
||||
public SubQuery<JM,A> orderBy(OrderSpecifier<?>... o) {query.orderBy(o); return this;}
|
||||
public SubQuery<JM,A> select(Expr<?>... o) {query.s(o); return this;}
|
||||
public SubQuery<JM,A> select(Expr<?>... o) {
|
||||
query.s(o); return this;}
|
||||
public SubQuery<JM,A> where(EBoolean... o) {query.where(o); return this;}
|
||||
public SubQuery<JM,A> with(EBoolean o) {query.with(o); return this;}
|
||||
// TODO : add some validation that the given Projection is valid for this subquery
|
||||
public Alias.ASimple<A> as(Projection to) { return new Alias.ASimple<A>(this, to.getName()); }
|
||||
public Alias.ASimple<A> as(Projection to) {
|
||||
to.accept(this);
|
||||
return new Alias.ASimple<A>(this, to.getName());
|
||||
}
|
||||
public Alias.ASimple<A> as(String to) { return new Alias.ASimple<A>(this, to); }
|
||||
|
||||
private static class QueryWithPublicSelect<JM> extends QueryBase<JM,QueryWithPublicSelect<JM>>{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user