mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-24 21:07:26 +08:00
#411 Add test
This commit is contained in:
parent
6873e9810d
commit
492ccdbb36
@ -37,11 +37,13 @@ import com.mysema.commons.lang.CloseableIterator;
|
||||
import com.mysema.query.jpa.JPASubQuery;
|
||||
import com.mysema.query.jpa.domain.Cat;
|
||||
import com.mysema.query.jpa.domain.QCat;
|
||||
import com.mysema.query.jpa.domain.QCatSummary;
|
||||
import com.mysema.query.jpa.domain.QChild;
|
||||
import com.mysema.query.jpa.domain.QParent;
|
||||
import com.mysema.query.jpa.impl.JPADeleteClause;
|
||||
import com.mysema.query.jpa.impl.JPAQuery;
|
||||
import com.mysema.query.types.EntityPath;
|
||||
import com.mysema.query.types.expr.BooleanExpression;
|
||||
import com.mysema.testutil.ExcludeIn;
|
||||
import com.mysema.testutil.JPATestRunner;
|
||||
|
||||
@ -219,4 +221,14 @@ public class JPABase extends AbstractStandardTest {
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Subquery_UniqueResult() {
|
||||
QCat cat2 = new QCat("cat2");
|
||||
|
||||
BooleanExpression exists = new JPASubQuery().from(cat2).where(cat2.eyecolor.isNotNull()).exists();
|
||||
assertNotNull(query().from(cat)
|
||||
.where(cat.breed.eq(0).not())
|
||||
.singleResult(new QCatSummary(cat.breed.count(), exists)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
package com.mysema.query.jpa.domain;
|
||||
|
||||
import com.mysema.query.annotations.QueryProjection;
|
||||
|
||||
public class CatSummary {
|
||||
|
||||
private long breeders;
|
||||
|
||||
private boolean hasEyeColoredCat;
|
||||
|
||||
@QueryProjection
|
||||
public CatSummary(long breeders, boolean hasEyeColoredCat) {
|
||||
super();
|
||||
this.breeders = breeders;
|
||||
this.hasEyeColoredCat = hasEyeColoredCat;
|
||||
}
|
||||
|
||||
public long getBreeders() {
|
||||
return breeders;
|
||||
}
|
||||
|
||||
public void setBreeders(long breeders) {
|
||||
this.breeders = breeders;
|
||||
}
|
||||
|
||||
public boolean isHasEyeColoredCat() {
|
||||
return hasEyeColoredCat;
|
||||
}
|
||||
|
||||
public void setHasEyeColoredCat(boolean hasEyeColoredCat) {
|
||||
this.hasEyeColoredCat = hasEyeColoredCat;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user