use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLJoinsIT method testChainedJoins.
@Test
public void testChainedJoins() throws Exception {
createTwoArtistsTwoPaintingsTwoGalleries();
String ejbql = "SELECT a FROM Artist a JOIN a.paintingArray p JOIN p.toGallery g " + "WHERE g.galleryName = 'gallery2'";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> artists = context.performQuery(query);
assertEquals(1, artists.size());
assertEquals(33002, Cayenne.intPKForObject((Artist) artists.get(0)));
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLJoinsIT method testImplicitJoins_OUTER_InTheMiddle.
@Test
public void testImplicitJoins_OUTER_InTheMiddle() throws Exception {
tGallery.insert(33001, "gallery1");
tGallery.insert(33002, "gallery2");
tArtist.insert(33001, "AA1");
tArtist.insert(33002, "AA2");
tPainting.insert(33005, 33001, 33001, "CC1", 5000);
tPainting.insert(33006, 33001, 33002, "CC2", 5000);
String ejbql = "SELECT a FROM Artist a WHERE a.paintingArray+.toGallery is null";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> artists = context.performQuery(query);
assertEquals(1, artists.size());
assertEquals(33002, Cayenne.intPKForObject((Artist) artists.get(0)));
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLJoinsIT method testInnerJoins.
@Test
public void testInnerJoins() throws Exception {
createTwoArtistsOnePainting();
String ejbql = "SELECT a FROM Artist a INNER JOIN a.paintingArray p " + "WHERE a.artistName = 'AA1'";
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.
@Test
public void testImplicitJoins() throws Exception {
createTwoArtistsTwoPaintingsTwoGalleries();
String ejbql = "SELECT a FROM Artist a WHERE a.paintingArray.toGallery.galleryName = 'gallery2'";
EJBQLQuery query = new EJBQLQuery(ejbql);
List<?> artists = context.performQuery(query);
assertEquals(1, artists.size());
assertEquals(33002, Cayenne.intPKForObject((Artist) artists.get(0)));
}
use of org.apache.cayenne.query.EJBQLQuery in project cayenne by apache.
the class DataContextEJBQLJoinsIT method testPartialImplicitJoins2.
@Test
public void testPartialImplicitJoins2() throws Exception {
createTwoArtistsTwoPaintingsTwoGalleries();
String ejbql = "SELECT a " + "FROM Artist a JOIN a.paintingArray b " + "WHERE a.paintingArray.paintingTitle = 'CC2'";
List<?> artists = context.performQuery(new EJBQLQuery(ejbql));
assertEquals(1, artists.size());
assertEquals(33002, Cayenne.intPKForObject((Artist) artists.get(0)));
}
Aggregations