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
2a138217b4
@ -71,6 +71,10 @@ public interface Group {
|
||||
*/
|
||||
Tuple getRow(int i);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int size();
|
||||
|
||||
}
|
||||
|
||||
@ -35,9 +35,7 @@ public class GroupBy implements ResultTransformer<Collection<Group>> {
|
||||
public GroupBy(Expression<?> groupBy, Expression<?>... args) {
|
||||
expressions = new Expression<?>[args.length + 1];
|
||||
expressions[0] = groupBy;
|
||||
for (int i=0; i < args.length; i++) {
|
||||
expressions[i+1] = args[i];
|
||||
}
|
||||
System.arraycopy(args, 0, expressions, 1, args.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,9 +48,9 @@ public class GroupBy implements ResultTransformer<Collection<Group>> {
|
||||
Object[] row = iter.next();
|
||||
Object groupBy = row[0];
|
||||
// groups.values() should return Collection<GTuple> instead of Collection<? extends GTuple>
|
||||
GTupleImpl group = (GTupleImpl) groups.get(groupBy);
|
||||
GroupImpl group = (GroupImpl) groups.get(groupBy);
|
||||
if (group == null) {
|
||||
group = new GTupleImpl();
|
||||
group = new GroupImpl();
|
||||
groups.put(groupBy, group);
|
||||
}
|
||||
group.add(row);
|
||||
@ -73,7 +71,7 @@ public class GroupBy implements ResultTransformer<Collection<Group>> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private class GTupleImpl implements Group {
|
||||
private class GroupImpl implements Group {
|
||||
|
||||
private final List<Object[]> values = new ArrayList<Object[]>();
|
||||
|
||||
|
||||
@ -27,11 +27,11 @@ import com.mysema.query.types.path.StringPath;
|
||||
|
||||
public class GroupByTest {
|
||||
|
||||
private final NumberExpression<Integer> postId = new NumberPath<Integer>(Integer.class, null, "postId");
|
||||
private final NumberExpression<Integer> postId = new NumberPath<Integer>(Integer.class, "postId");
|
||||
|
||||
private final StringExpression postName = new StringPath(null, "postName");
|
||||
private final StringExpression postName = new StringPath("postName");
|
||||
|
||||
private final NumberExpression<Integer> commentId = new NumberPath<Integer>(Integer.class, null, "commentId");
|
||||
private final NumberExpression<Integer> commentId = new NumberPath<Integer>(Integer.class, "commentId");
|
||||
|
||||
static class PostWithComments {
|
||||
public Integer id;
|
||||
@ -191,7 +191,9 @@ public class GroupByTest {
|
||||
return row;
|
||||
}
|
||||
|
||||
private static CloseableIterator<Object[]> iterator(Object[]... rows) {
|
||||
return new IteratorAdapter<Object[]>(Arrays.asList(rows).iterator());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> CloseableIterator<T> iterator(Object[]... rows) {
|
||||
return new IteratorAdapter(Arrays.asList(rows).iterator());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user