Search in sources :

Example 71 with EJBQLQuery

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)));
}
Also used : EJBQLQuery(org.apache.cayenne.query.EJBQLQuery) Persistent(org.apache.cayenne.Persistent) Test(org.junit.Test)

Example 72 with EJBQLQuery

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)));
}
Also used : EJBQLQuery(org.apache.cayenne.query.EJBQLQuery) Persistent(org.apache.cayenne.Persistent) Test(org.junit.Test)

Example 73 with EJBQLQuery

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)));
}
Also used : EJBQLQuery(org.apache.cayenne.query.EJBQLQuery) Persistent(org.apache.cayenne.Persistent) Test(org.junit.Test)

Example 74 with EJBQLQuery

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)));
}
Also used : Artist(org.apache.cayenne.testdo.testmap.Artist) EJBQLQuery(org.apache.cayenne.query.EJBQLQuery) Test(org.junit.Test)

Example 75 with EJBQLQuery

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)));
}
Also used : Artist(org.apache.cayenne.testdo.testmap.Artist) EJBQLQuery(org.apache.cayenne.query.EJBQLQuery) Test(org.junit.Test)

Aggregations

EJBQLQuery (org.apache.cayenne.query.EJBQLQuery)160 Test (org.junit.Test)158 Artist (org.apache.cayenne.testdo.testmap.Artist)39 HashSet (java.util.HashSet)35 Painting (org.apache.cayenne.testdo.testmap.Painting)15 QueryResponse (org.apache.cayenne.QueryResponse)12 BigDecimal (java.math.BigDecimal)10 Persistent (org.apache.cayenne.Persistent)10 List (java.util.List)9 ArrayList (java.util.ArrayList)7 FlattenedTest1 (org.apache.cayenne.testdo.relationships_flattened.FlattenedTest1)6 CompoundPainting (org.apache.cayenne.testdo.testmap.CompoundPainting)5 UnitTestClosure (org.apache.cayenne.unit.di.UnitTestClosure)5 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 ValueHolder (org.apache.cayenne.ValueHolder)4 CompoundPkTestEntity (org.apache.cayenne.testdo.compound.CompoundPkTestEntity)4 Gallery (org.apache.cayenne.testdo.testmap.Gallery)4 Calendar (java.util.Calendar)3 EJBQLCompiledExpression (org.apache.cayenne.ejbql.EJBQLCompiledExpression)3