Search in sources :

Example 31 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class SelectQueryClobIT method testSelectEqualsClob.

@Test
public void testSelectEqualsClob() throws Exception {
    if (accessStackAdapter.supportsLobComparisons()) {
        createClobDataSet();
        SelectQuery<ClobTestEntity> query = new SelectQuery<ClobTestEntity>(ClobTestEntity.class);
        Expression qual = ExpressionFactory.matchExp("clobCol", "clob1");
        query.setQualifier(qual);
        List<?> objects = context.performQuery(query);
        assertEquals(1, objects.size());
    }
}
Also used : Expression(org.apache.cayenne.exp.Expression) ClobTestEntity(org.apache.cayenne.testdo.lob.ClobTestEntity) Test(org.junit.Test)

Example 32 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class SelectQueryClobIT method testSelectNotEqualsClob.

@Test
public void testSelectNotEqualsClob() throws Exception {
    if (accessStackAdapter.supportsLobComparisons()) {
        createClobDataSet();
        SelectQuery query = new SelectQuery(ClobTestEntity.class);
        Expression qual = ExpressionFactory.noMatchExp("clobCol", "clob1");
        query.setQualifier(qual);
        List<?> objects = context.performQuery(query);
        assertEquals(1, objects.size());
    }
}
Also used : Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 33 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class SelectQueryIT method testSelectNotLikeSingleWildcardMatch.

@Test
public void testSelectNotLikeSingleWildcardMatch() throws Exception {
    createArtistsDataSet();
    SelectQuery<Artist> query = new SelectQuery<>(Artist.class);
    Expression qual = ExpressionFactory.notLikeExp("artistName", "artist11%");
    query.setQualifier(qual);
    List<?> objects = context.performQuery(query);
    assertEquals(19, objects.size());
}
Also used : Artist(org.apache.cayenne.testdo.testmap.Artist) Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 34 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class SelectQueryIT method testSelectLikeCaseSensitive.

/**
 * SQL Server failure:
 * http://stackoverflow.com/questions/14962419/is-the-like-operator-case-sensitive-with-ms-sql-server
 */
@Test
public void testSelectLikeCaseSensitive() throws Exception {
    if (!accessStackAdapter.supportsCaseSensitiveLike()) {
        return;
    }
    createArtistsDataSet();
    SelectQuery<Artist> query = new SelectQuery<>(Artist.class);
    Expression qual = ExpressionFactory.likeExp("artistName", "aRtIsT%");
    query.setQualifier(qual);
    List<?> objects = context.performQuery(query);
    assertEquals(0, objects.size());
}
Also used : Artist(org.apache.cayenne.testdo.testmap.Artist) Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Example 35 with Expression

use of org.apache.cayenne.exp.Expression in project cayenne by apache.

the class SelectQueryIT method testSelectEmptyIn.

@Test
public void testSelectEmptyIn() throws Exception {
    createArtistsDataSet();
    SelectQuery<Artist> query = new SelectQuery<>(Artist.class);
    Expression qual = ExpressionFactory.inExp("artistName");
    query.setQualifier(qual);
    List<?> objects = context.performQuery(query);
    assertEquals(0, objects.size());
}
Also used : Artist(org.apache.cayenne.testdo.testmap.Artist) Expression(org.apache.cayenne.exp.Expression) Test(org.junit.Test)

Aggregations

Expression (org.apache.cayenne.exp.Expression)298 Test (org.junit.Test)265 Artist (org.apache.cayenne.testdo.testmap.Artist)69 SelectQuery (org.apache.cayenne.query.SelectQuery)47 Painting (org.apache.cayenne.testdo.testmap.Painting)29 BigDecimal (java.math.BigDecimal)23 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)17 DateTestEntity (org.apache.cayenne.testdo.date_time.DateTestEntity)16 ObjEntity (org.apache.cayenne.map.ObjEntity)13 ClientMtTable1 (org.apache.cayenne.testdo.mt.ClientMtTable1)12 DbEntity (org.apache.cayenne.map.DbEntity)10 List (java.util.List)9 HashMap (java.util.HashMap)8 DataRow (org.apache.cayenne.DataRow)8 DbAttribute (org.apache.cayenne.map.DbAttribute)8 ClientMtTable2 (org.apache.cayenne.testdo.mt.ClientMtTable2)7 DbRelationship (org.apache.cayenne.map.DbRelationship)6 ObjAttribute (org.apache.cayenne.map.ObjAttribute)6 ObjRelationship (org.apache.cayenne.map.ObjRelationship)6 Gallery (org.apache.cayenne.testdo.testmap.Gallery)6