use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testFetchLimit.
@Test
public void testFetchLimit() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select a FROM Artist a";
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setFetchLimit(2);
List<?> artists = context.performQuery(query);
assertEquals(2, artists.size());
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectFromWhereGreaterOrEqual.
@Test
public void testSelectFromWhereGreaterOrEqual() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select P from Painting P WHERE p.estimatedPrice >= 3000";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> ps = context.performQuery(query);
assertEquals(2, ps.size());
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectFromWhereGreater.
@Test
public void testSelectFromWhereGreater() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select P from Painting P WHERE p.estimatedPrice > 3000";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
Painting p = (Painting) ps.get(0);
assertEquals("P2", p.getPaintingTitle());
assertEquals(5000d, p.getEstimatedPrice().doubleValue(), 0.00001);
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectDbPath_Relationship.
@Test
public void testSelectDbPath_Relationship() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select db:p.toArtist " + "from Painting p order by p.estimatedPrice";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> data = context.performQuery(query);
assertEquals(2, data.size());
assertTrue(data.get(0) instanceof Artist);
assertEquals(33001, Cayenne.intPKForObject((Artist) data.get(0)));
assertTrue(data.get(1) instanceof Artist);
assertEquals(33002, Cayenne.intPKForObject((Artist) data.get(1)));
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLQueryIT method testSelectFromWhereEqual.
@Test
public void testSelectFromWhereEqual() throws Exception {
createFourArtistsTwoPaintings();
String ejbql = "select a from Artist a where a.artistName = 'AA2'";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> artists = context.performQuery(query);
assertEquals(1, artists.size());
assertEquals("AA2", ((Artist) artists.get(0)).getArtistName());
}
Aggregations