mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
added sub query test
This commit is contained in:
parent
c87b399d82
commit
12a81eb0ea
@ -35,7 +35,7 @@ public abstract class AbstractJPATest extends AbstractStandardTest{
|
||||
protected JPAQuery query(){
|
||||
return new JPAQuery(entityManager, getTemplates());
|
||||
}
|
||||
|
||||
|
||||
protected JPQLTemplates getTemplates(){
|
||||
return HQLTemplates.DEFAULT;
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import org.junit.Test;
|
||||
|
||||
import com.mysema.commons.lang.Pair;
|
||||
import com.mysema.query.jpa.JPQLQuery;
|
||||
import com.mysema.query.jpa.JPQLSubQuery;
|
||||
import com.mysema.query.jpa.domain.Cat;
|
||||
import com.mysema.query.jpa.domain.DomesticCat;
|
||||
import com.mysema.query.jpa.domain.QCat;
|
||||
@ -125,6 +126,10 @@ public abstract class AbstractStandardTest {
|
||||
protected abstract Target getTarget();
|
||||
|
||||
protected abstract JPQLQuery query();
|
||||
|
||||
protected JPQLSubQuery subQuery(){
|
||||
return new JPQLSubQuery();
|
||||
}
|
||||
|
||||
protected abstract void save(Object entity);
|
||||
|
||||
@ -432,5 +437,12 @@ public abstract class AbstractStandardTest {
|
||||
assertEquals(1l, query().from(show).where(show.acts.containsValue("B")).count());
|
||||
assertEquals(0l, query().from(show).where(show.acts.containsValue("C")).count());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SubQuery(){
|
||||
QShow show = QShow.show;
|
||||
QShow show2 = new QShow("show2");
|
||||
query().from(show).where(subQuery().from(show2).where(show2.id.ne(show.id)).count().gt(0)).count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user