added sub query test

This commit is contained in:
Timo Westkämper 2011-04-19 18:19:37 +00:00
parent c87b399d82
commit 12a81eb0ea
2 changed files with 13 additions and 1 deletions

View File

@ -35,7 +35,7 @@ public abstract class AbstractJPATest extends AbstractStandardTest{
protected JPAQuery query(){
return new JPAQuery(entityManager, getTemplates());
}
protected JPQLTemplates getTemplates(){
return HQLTemplates.DEFAULT;
}

View File

@ -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();
}
}