Search in sources :

Example 1 with QProduct

use of com.querydsl.jdo.test.domain.QProduct in project querydsl by querydsl.

the class QueryMutabilityTest method clone_.

@Test
public void clone_() {
    QProduct product = QProduct.product;
    JDOQuery<?> query = new JDOQuery<Void>().from(product).where(product.name.isNotNull());
    JDOQuery<?> query2 = query.clone(pm);
    assertEquals(query.getMetadata().getJoins(), query2.getMetadata().getJoins());
    assertEquals(query.getMetadata().getWhere(), query2.getMetadata().getWhere());
    query2.select(product).fetch();
}
Also used : QProduct(com.querydsl.jdo.test.domain.QProduct) Test(org.junit.Test)

Example 2 with QProduct

use of com.querydsl.jdo.test.domain.QProduct in project querydsl by querydsl.

the class QueryMutabilityTest method queryMutability.

@Test
public void queryMutability() throws IOException, SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    QProduct product = QProduct.product;
    JDOQuery<?> query = query().from(product);
    new QueryMutability(query).test(product.name, product.description);
}
Also used : QueryMutability(com.querydsl.core.QueryMutability) QProduct(com.querydsl.jdo.test.domain.QProduct) Test(org.junit.Test)

Example 3 with QProduct

use of com.querydsl.jdo.test.domain.QProduct in project querydsl by querydsl.

the class FetchPlanTest method listProducts.

@SuppressWarnings("unchecked")
@Test
public void listProducts() throws Exception {
    QProduct product = QProduct.product;
    query = query();
    query.from(product).where(product.name.startsWith("A")).addFetchGroup("myfetchgroup1").addFetchGroup("myfetchgroup2").setMaxFetchDepth(2).select(product).fetch();
    //        query.close();
    Field queriesField = AbstractJDOQuery.class.getDeclaredField("queries");
    queriesField.setAccessible(true);
    List<Query> queries = (List<Query>) queriesField.get(query);
    Query jdoQuery = queries.get(0);
    assertEquals(new HashSet<String>(Arrays.asList("myfetchgroup1", "myfetchgroup2")), jdoQuery.getFetchPlan().getGroups());
    assertEquals(2, jdoQuery.getFetchPlan().getMaxFetchDepth());
}
Also used : Field(java.lang.reflect.Field) Query(javax.jdo.Query) List(java.util.List) QProduct(com.querydsl.jdo.test.domain.QProduct) Test(org.junit.Test)

Aggregations

QProduct (com.querydsl.jdo.test.domain.QProduct)3 Test (org.junit.Test)3 QueryMutability (com.querydsl.core.QueryMutability)1 Field (java.lang.reflect.Field)1 List (java.util.List)1 Query (javax.jdo.Query)1