use of org.apache.cayenne.Persistent in project cayenne by apache.
the class DataContextEJBQLIsNullIT method testIsNull.
@Test
public void testIsNull() throws Exception {
createTwoPaintings();
String ejbql1 = "SELECT p FROM Painting p WHERE p.estimatedPrice IS NULL";
EJBQLQuery query1 = new EJBQLQuery(ejbql1);
List<?> results = context.performQuery(query1);
assertEquals(1, results.size());
assertEquals(33001, Cayenne.intPKForObject((Persistent) results.get(0)));
}
use of org.apache.cayenne.Persistent in project cayenne by apache.
the class DataContextEJBQLIsNullIT method testToOneIsNull.
@Test
public void testToOneIsNull() throws Exception {
createTwoPaintingsAndOneArtist();
String ejbql1 = "SELECT p FROM Painting p WHERE p.toArtist IS NULL";
EJBQLQuery query1 = new EJBQLQuery(ejbql1);
List<?> results = context.performQuery(query1);
assertEquals(1, results.size());
assertEquals(33001, Cayenne.intPKForObject((Persistent) results.get(0)));
}
use of org.apache.cayenne.Persistent in project cayenne by apache.
the class DataContextEJBQLIsNullIT method testToOneIsNotNull.
@Test
public void testToOneIsNotNull() throws Exception {
createTwoPaintingsAndOneArtist();
String ejbql1 = "SELECT p FROM Painting p WHERE p.toArtist IS NOT NULL";
EJBQLQuery query1 = new EJBQLQuery(ejbql1);
List<?> results = context.performQuery(query1);
assertEquals(1, results.size());
assertEquals(33003, Cayenne.intPKForObject((Persistent) results.get(0)));
}
use of org.apache.cayenne.Persistent in project cayenne by apache.
the class DataContextEJBQLOrderByIT method testOrderByAsc.
@Test
public void testOrderByAsc() throws Exception {
createThreePaintings();
String ejbql1 = "SELECT p FROM Painting p ORDER BY p.paintingTitle ASC";
EJBQLQuery query1 = new EJBQLQuery(ejbql1);
List<?> results1 = context.performQuery(query1);
assertEquals(3, results1.size());
assertEquals(33001, Cayenne.intPKForObject((Persistent) results1.get(0)));
assertEquals(33002, Cayenne.intPKForObject((Persistent) results1.get(1)));
assertEquals(33003, Cayenne.intPKForObject((Persistent) results1.get(2)));
String ejbql2 = "SELECT p FROM Painting p ORDER BY p.estimatedPrice ASC";
EJBQLQuery query2 = new EJBQLQuery(ejbql2);
List<?> results2 = context.performQuery(query2);
assertEquals(3, results2.size());
assertEquals(33003, Cayenne.intPKForObject((Persistent) results2.get(0)));
assertEquals(33002, Cayenne.intPKForObject((Persistent) results2.get(1)));
assertEquals(33001, Cayenne.intPKForObject((Persistent) results2.get(2)));
}
use of org.apache.cayenne.Persistent in project cayenne by apache.
the class DataContextEJBQLOrderByIT method testOrderByMultiple.
@Test
public void testOrderByMultiple() throws Exception {
createFourPaintings();
String ejbql1 = "SELECT p FROM Painting p ORDER BY p.paintingTitle DESC, p.estimatedPrice DESC";
EJBQLQuery query1 = new EJBQLQuery(ejbql1);
List<?> results1 = context.performQuery(query1);
assertEquals(4, results1.size());
assertEquals(33003, Cayenne.intPKForObject((Persistent) results1.get(0)));
assertEquals(33004, Cayenne.intPKForObject((Persistent) results1.get(1)));
assertEquals(33002, Cayenne.intPKForObject((Persistent) results1.get(2)));
assertEquals(33001, Cayenne.intPKForObject((Persistent) results1.get(3)));
}
Aggregations