extended DetachableQuery

This commit is contained in:
Timo Westkämper 2010-01-21 14:12:28 +00:00
parent 739fbfcf4d
commit a875cd8d25
3 changed files with 42 additions and 1 deletions

View File

@ -35,6 +35,14 @@ public interface Detachable {
* @return a List over the projection
*/
ListSubQuery<Object[]> list(Expr<?> first, Expr<?> second, Expr<?>... rest);
/**
*
*
* @param args
* @return
*/
ListSubQuery<Object[]> list(Expr<?>[] args);
/**
* Create a projection expression for the given projection
@ -55,6 +63,14 @@ public interface Detachable {
* @return
*/
ObjectSubQuery<Object[]> unique(Expr<?> first, Expr<?> second, Expr<?>... rest);
/**
* Create a projection expression for the given projection
*
* @param args
* @return
*/
ObjectSubQuery<Object[]> unique(Expr<?>[] args);
/**
* Create a projection expression for the given projection

View File

@ -33,6 +33,13 @@ public class DetachableMixin implements Detachable{
queryMixin.addToProjection(Ops.AggOps.COUNT_ALL_AGG_EXPR);
return new ObjectSubQuery<Long>(queryMixin.getMetadata(), Long.class);
}
@Override
public ListSubQuery<Object[]> list(Expr<?>[] args) {
queryMixin.addToProjection(args);
return new ListSubQuery<Object[]>(queryMixin.getMetadata(), Object[].class);
}
@Override
public ListSubQuery<Object[]> list(Expr<?> first, Expr<?> second, Expr<?>... rest) {
@ -47,6 +54,14 @@ public class DetachableMixin implements Detachable{
queryMixin.addToProjection(projection);
return new ListSubQuery<RT>(queryMixin.getMetadata(), (Class)projection.getType());
}
@Override
public ObjectSubQuery<Object[]> unique(Expr<?>[] args) {
queryMixin.addToProjection(args);
queryMixin.setUnique(true);
return new ObjectSubQuery<Object[]>(queryMixin.getMetadata(), Object[].class);
}
@Override
public ObjectSubQuery<Object[]> unique(Expr<?> first, Expr<?> second, Expr<?>... rest) {

View File

@ -18,7 +18,7 @@ import com.mysema.query.types.query.ObjectSubQuery;
*
* @param <SubType>
*/
public abstract class DetachableQuery <SubType extends DetachableQuery<SubType>> extends QueryBase<SubType> implements Detachable {
public class DetachableQuery <SubType extends DetachableQuery<SubType>> extends QueryBase<SubType> implements Detachable {
private final DetachableMixin detachableMixin;
@ -62,4 +62,14 @@ public abstract class DetachableQuery <SubType extends DetachableQuery<SubType>>
return detachableMixin.unique(projection);
}
@Override
public ListSubQuery<Object[]> list(Expr<?>[] args) {
return detachableMixin.list(args);
}
@Override
public ObjectSubQuery<Object[]> unique(Expr<?>[] args) {
return detachableMixin.unique(args);
}
}