use of org.apache.cayenne.query.EJBQLQuery 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.query.EJBQLQuery 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.query.EJBQLQuery 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.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLJoinsIT method testMultipleJoinsToTheSameTable.
@Test
public void testMultipleJoinsToTheSameTable() throws Exception {
createTwoArtistsThreePaintings();
String ejbql = "SELECT a " + "FROM Artist a JOIN a.paintingArray b JOIN a.paintingArray c " + "WHERE b.paintingTitle = 'P1' AND c.paintingTitle = 'P2'";
List<?> artists = context.performQuery(new EJBQLQuery(ejbql));
assertEquals(1, artists.size());
assertEquals(33001, Cayenne.intPKForObject((Artist) artists.get(0)));
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLJoinsIT method testImplicitJoins_OUTER_LastComponent.
@Test
public void testImplicitJoins_OUTER_LastComponent() throws Exception {
tArtist.insert(33001, "AA1");
tArtist.insert(33002, "AA2");
tPainting.insert(33005, 33001, null, "CC1", 5000);
tPainting.insert(33006, 33001, null, "CC2", 5000);
String ejbql = "SELECT a FROM Artist a WHERE a.paintingArray+ is null";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> artists = context.performQuery(query);
assertEquals(1, artists.size());
assertEquals(33002, Cayenne.intPKForObject((Artist) artists.get(0)));
}
Aggregations