This commit is contained in:
Timo Westkämper 2008-02-23 12:56:46 +00:00
parent 8bb1c22833
commit 69db91bc75
4 changed files with 46 additions and 34 deletions

View File

@ -14,7 +14,7 @@ import com.mysema.query.grammar.Types.EntityExpr;
* @author tiwe
* @version $Id$
*/
public interface ExtQuery<A extends ExtQuery<?>> extends Query<A> {
public interface ExtQuery<A extends ExtQuery<A>> extends Query<A> {
A innerJoin(EntityExpr<?> object);
A join(EntityExpr<?> object);
A leftJoin(EntityExpr<?> object);

View File

@ -17,7 +17,7 @@ import com.mysema.query.grammar.Types.OrderSpecifier;
* @author tiwe
* @version $Id$
*/
public interface Query<A extends Query<?>>{
public interface Query<A extends Query<A>>{
A select(Expr<?>... objects);
A from(EntityExpr<?>... objects);
A where(BooleanExpr... objects);

View File

@ -1,5 +1,8 @@
package com.mysema.query;
import java.util.ArrayList;
import java.util.List;
import com.mysema.query.grammar.Types.BooleanExpr;
import com.mysema.query.grammar.Types.EntityExpr;
import com.mysema.query.grammar.Types.Expr;
@ -10,80 +13,87 @@ import com.mysema.query.grammar.Types.OrderSpecifier;
* @author tiwe
* @version $Id$
*/
public class QueryBase implements ExtQuery<QueryBase> {
@SuppressWarnings("unchecked")
public class QueryBase<A extends QueryBase<A>> implements ExtQuery<A> {
public enum JoinType{
DEFAULT,IJ,LJ,J
}
protected EntityExpr<?>[] from;
public class JoinExpression{
public final JoinType type;
public final EntityExpr<?> target;
JoinExpression(JoinType type, EntityExpr<?> target){
this.type = type;
this.target = target;
}
public BooleanExpr[] conditions;
}
protected List<JoinExpression> joins = new ArrayList<JoinExpression>();
protected Expr<?>[] groupBy;
protected BooleanExpr[] having;
// protected EntityExpr<?>[] innerJoin;
// protected EntityExpr<?>[] join;
// protected EntityExpr<?>[] leftJoin;
protected OrderSpecifier<?>[] orderBy;
protected Expr<?>[] select;
protected BooleanExpr[] where;
protected BooleanExpr[] with;
protected void clear(){
from = null;
joins.clear();
groupBy = null;
having = null;
// innerJoin = null;
// join = null;
// leftJoin = null;
orderBy = null;
select = null;
where = null;
with = null;
}
public QueryBase from(EntityExpr<?>... objects) {
from = objects;
return this;
public A from(EntityExpr<?>... objects) {
// TODO
return (A) this;
}
public QueryBase groupBy(Expr<?>... objects) {
public A groupBy(Expr<?>... objects) {
groupBy = objects;
return this;
return (A) this;
}
public QueryBase having(BooleanExpr... objects) {
public A having(BooleanExpr... objects) {
having = objects;
return this;
return (A) this;
}
public QueryBase innerJoin(EntityExpr<?> object) {
public A innerJoin(EntityExpr<?> object) {
// innerJoin = objects;
return this;
return (A) this;
}
public QueryBase join(EntityExpr<?> object) {
public A join(EntityExpr<?> object) {
// join = objects;
return this;
return (A) this;
}
public QueryBase leftJoin(EntityExpr<?> object) {
public A leftJoin(EntityExpr<?> object) {
// leftJoin = objects;
return this;
return (A) this;
}
public QueryBase orderBy(OrderSpecifier<?>... objects) {
public A orderBy(OrderSpecifier<?>... objects) {
orderBy = objects;
return this;
return (A) this;
}
public QueryBase select(Expr<?>... objects) {
public A select(Expr<?>... objects) {
select = objects;
return this;
return (A) this;
}
public QueryBase where(BooleanExpr... objects) {
public A where(BooleanExpr... objects) {
where = objects;
return this;
return (A) this;
}
public QueryBase with(BooleanExpr... objects) {
public A with(BooleanExpr... objects) {
with = objects;
return this;
return (A) this;
}
}

View File

@ -35,7 +35,9 @@ public abstract class Visitor<T extends Visitor<T>> {
sigClass = sigClass.getSuperclass();
}
}
method.setAccessible(true);
if (method != null){
method.setAccessible(true);
}
return method;
} catch (Exception e) {
throw new RuntimeException(e);