use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class EJBQLQueryDescriptor method buildQuery.
@Override
public EJBQLQuery buildQuery() {
EJBQLQuery ejbqlQuery = new EJBQLQuery(this.getEjbql());
ejbqlQuery.initWithProperties(this.getProperties());
return ejbqlQuery;
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class CayenneContextEJBQLIT method testEJBQLSelect.
@Test
public void testEJBQLSelect() throws Exception {
createTwoRecords();
EJBQLQuery query = new EJBQLQuery("SELECT a FROM MtTable1 a");
List<ClientMtTable1> results = context.performQuery(query);
assertEquals(2, results.size());
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectFromWhereMatchOnObject.
@Test
public void testSelectFromWhereMatchOnObject() throws Exception {
createFourArtistsTwoPaintings();
Artist a = Cayenne.objectForPK(context, Artist.class, 33002);
String ejbql = "select P from Painting P WHERE p.toArtist = :param";
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("param", a);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
Painting p = (Painting) ps.get(0);
assertEquals(33002, Cayenne.intPKForObject(p));
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectDbPath.
@Test
public void testSelectDbPath() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select db:p.ESTIMATED_PRICE " + "from Painting p order by p.estimatedPrice";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> data = context.performQuery(query);
assertEquals(2, data.size());
assertEquals(3000d, ((BigDecimal) data.get(0)).doubleValue(), 0.00001);
assertEquals(5000d, ((BigDecimal) data.get(1)).doubleValue(), 0.00001);
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSimpleSelect.
@Test
public void testSimpleSelect() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select a FROM Artist a";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> artists = context.performQuery(query);
assertEquals(4, artists.size());
assertTrue(artists.get(0) instanceof Artist);
assertTrue(((Artist) artists.get(0)).getPersistenceState() == PersistenceState.COMMITTED);
}
Aggregations