cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [1/2] cayenne git commit: cleanup, no change
Date Wed, 10 Dec 2014 08:33:16 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 6438dc7e0 -> 2894d5ffa


cleanup, no change


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/0ffb210d
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/0ffb210d
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/0ffb210d

Branch: refs/heads/master
Commit: 0ffb210dd5f0b4a1b47651b9f8cc7540bd0522bd
Parents: 6438dc7
Author: aadamchik <aadamchik@apache.org>
Authored: Wed Dec 10 11:13:55 2014 +0300
Committer: aadamchik <aadamchik@apache.org>
Committed: Wed Dec 10 11:14:07 2014 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/query/SelectQueryIT.java | 1210 +++++++++---------
 1 file changed, 607 insertions(+), 603 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/0ffb210d/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryIT.java
index 8421310..74a738a 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/SelectQueryIT.java
@@ -19,6 +19,17 @@
 
 package org.apache.cayenne.query;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.cayenne.Cayenne;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ObjectContext;
@@ -40,264 +51,256 @@ import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.CayenneProjects;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
+import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
 @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
 public class SelectQueryIT extends ServerCase {
 
-    @Inject
-    private ObjectContext context;
+	@Inject
+	private ObjectContext context;
+
+	@Inject
+	private DBHelper dbHelper;
+
+	@Inject
+	private UnitDbAdapter accessStackAdapter;
+
+	private TableHelper tArtist;
+
+	@Before
+	public void before() {
+		this.tArtist = new TableHelper(dbHelper, "ARTIST").setColumns("ARTIST_ID", "ARTIST_NAME",
"DATE_OF_BIRTH");
+	}
+
+	protected void createArtistsDataSet() throws Exception {
+
+		long dateBase = System.currentTimeMillis();
+
+		for (int i = 1; i <= 20; i++) {
+			tArtist.insert(i, "artist" + i, new java.sql.Date(dateBase + 10000 * i));
+		}
+	}
+
+	protected void createArtistsWildcardDataSet() throws Exception {
+		tArtist.insert(1, "_X", null);
+		tArtist.insert(2, "Y_", null);
+	}
+
+	@Test
+	public void testSetQualifier() {
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		assertNull(query.getQualifier());
+
+		Expression qual = ExpressionFactory.expressionOfType(Expression.AND);
+		query.setQualifier(qual);
+		assertNotNull(query.getQualifier());
+		assertSame(qual, query.getQualifier());
+	}
+
+	@Test
+	public void testAndQualifier() {
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		assertNull(query.getQualifier());
+
+		Expression e1 = ExpressionFactory.expressionOfType(Expression.EQUAL_TO);
+		query.andQualifier(e1);
+		assertSame(e1, query.getQualifier());
+
+		Expression e2 = ExpressionFactory.expressionOfType(Expression.NOT_EQUAL_TO);
+		query.andQualifier(e2);
+		assertEquals(Expression.AND, query.getQualifier().getType());
+	}
+
+	@Test
+	public void testOrQualifier() {
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		assertNull(query.getQualifier());
+
+		Expression e1 = ExpressionFactory.expressionOfType(Expression.EQUAL_TO);
+		query.orQualifier(e1);
+		assertSame(e1, query.getQualifier());
+
+		Expression e2 = ExpressionFactory.expressionOfType(Expression.NOT_EQUAL_TO);
+		query.orQualifier(e2);
+		assertEquals(Expression.OR, query.getQualifier().getType());
+	}
+
+	@Test
+	public void testFetchLimit() throws Exception {
+		createArtistsDataSet();
+
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		query.setFetchLimit(7);
+
+		List<?> objects = context.performQuery(query);
+		assertNotNull(objects);
+		assertEquals(7, objects.size());
+	}
+
+	@Test
+	public void testFetchOffset() throws Exception {
+
+		createArtistsDataSet();
+
+		int totalRows = context.select(new SelectQuery<Artist>(Artist.class)).size();
+
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		query.addOrdering("db:" + Artist.ARTIST_ID_PK_COLUMN, SortOrder.ASCENDING);
+		query.setFetchOffset(5);
+		List<Artist> results = context.select(query);
+
+		assertEquals(totalRows - 5, results.size());
+		assertEquals("artist6", results.get(0).getArtistName());
+	}
+
+	@Test
+	public void testDbEntityRoot() throws Exception {
+
+		createArtistsDataSet();
+		DbEntity artistDbEntity = context.getEntityResolver().getDbEntity("ARTIST");
+
+		SelectQuery query = new SelectQuery(artistDbEntity);
+		List<?> results = context.performQuery(query);
+
+		assertEquals(20, results.size());
+		assertTrue(results.get(0) instanceof DataRow);
+	}
+
+	@Test
+	public void testFetchLimitWithOffset() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		query.addOrdering("db:" + Artist.ARTIST_ID_PK_COLUMN, SortOrder.ASCENDING);
+		query.setFetchOffset(15);
+		query.setFetchLimit(4);
+		List<Artist> results = context.select(query);
+
+		assertEquals(4, results.size());
+		assertEquals("artist16", results.get(0).getArtistName());
+	}
+
+	@Test
+	public void testFetchOffsetWithQualifier() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		query.setQualifier(Expression.fromString("db:ARTIST_ID > 3"));
+		query.setFetchOffset(5);
+
+		List<?> objects = context.performQuery(query);
+		int size = objects.size();
+
+		SelectQuery<Artist> sizeQ = new SelectQuery<Artist>(Artist.class);
+		sizeQ.setQualifier(Expression.fromString("db:ARTIST_ID > 3"));
+		List<?> objects1 = context.performQuery(sizeQ);
+		int sizeAll = objects1.size();
+		assertEquals(size, sizeAll - 5);
+	}
+
+	@Test
+	public void testFetchLimitWithQualifier() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		query.setQualifier(Expression.fromString("db:ARTIST_ID > 3"));
+		query.setFetchLimit(7);
+		List<?> objects = context.performQuery(query);
+		assertEquals(7, objects.size());
+	}
+
+	@Test
+	public void testSelectAllObjectsRootEntityName() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>("Artist");
+		List<?> objects = context.performQuery(query);
+		assertEquals(20, objects.size());
+	}
+
+	@Test
+	public void testSelectAllObjectsRootClass() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		List<?> objects = context.performQuery(query);
+		assertEquals(20, objects.size());
+	}
+
+	@Test
+	public void testSelectAllObjectsRootObjEntity() throws Exception {
+		createArtistsDataSet();
+		ObjEntity artistEntity = context.getEntityResolver().getObjEntity(Artist.class);
+		SelectQuery<Artist> query = new SelectQuery<Artist>(artistEntity);
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(20, objects.size());
+	}
+
+	@Test
+	public void testSelectLikeExactMatch() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.likeExp("artistName", "artist1");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+	}
+
+	@Test
+	public void testSelectNotLikeSingleWildcardMatch() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.notLikeExp("artistName", "artist11%");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(19, objects.size());
+	}
 
-    @Inject
-    private DBHelper dbHelper;
+	@Test
+	public void testSelectNotLikeIgnoreCaseSingleWildcardMatch() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.notLikeIgnoreCaseExp("artistName", "aRtIsT11%");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(19, objects.size());
+	}
 
-    @Inject
-    private UnitDbAdapter accessStackAdapter;
+	@Test
+	public void testSelectLikeCaseSensitive() throws Exception {
+		if (!accessStackAdapter.supportsCaseSensitiveLike()) {
+			return;
+		}
 
-    protected void createArtistsDataSet() throws Exception {
-        TableHelper tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME", "DATE_OF_BIRTH");
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.likeExp("artistName", "aRtIsT%");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(0, objects.size());
+	}
 
-        long dateBase = System.currentTimeMillis();
+	@Test
+	public void testSelectLikeSingle_WildcardMatch() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.likeExp("artistName", "artist11%");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+	}
 
-        for (int i = 1; i <= 20; i++) {
-            tArtist.insert(i, "artist" + i, new java.sql.Date(dateBase + 10000 * i));
-        }
-    }
+	@Test
+	public void testSelectLikeSingle_WildcardMatchAndEscape() throws Exception {
 
-    protected void createArtistsWildcardDataSet() throws Exception {
-        TableHelper tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+		createArtistsWildcardDataSet();
 
-        tArtist.insert(1, "_X");
-        tArtist.insert(2, "Y_");
-    }
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		query.andQualifier(ExpressionFactory.likeExp("artistName", "=_%", '='));
 
-    @Test
-    public void testSetQualifier() {
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        assertNull(query.getQualifier());
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+	}
 
-        Expression qual = ExpressionFactory.expressionOfType(Expression.AND);
-        query.setQualifier(qual);
-        assertNotNull(query.getQualifier());
-        assertSame(qual, query.getQualifier());
-    }
-
-    @Test
-    public void testAndQualifier() {
-    	SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        assertNull(query.getQualifier());
-
-        Expression e1 = ExpressionFactory.expressionOfType(Expression.EQUAL_TO);
-        query.andQualifier(e1);
-        assertSame(e1, query.getQualifier());
-
-        Expression e2 = ExpressionFactory.expressionOfType(Expression.NOT_EQUAL_TO);
-        query.andQualifier(e2);
-        assertEquals(Expression.AND, query.getQualifier().getType());
-    }
-
-    @Test
-    public void testOrQualifier() {
-    	SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        assertNull(query.getQualifier());
-
-        Expression e1 = ExpressionFactory.expressionOfType(Expression.EQUAL_TO);
-        query.orQualifier(e1);
-        assertSame(e1, query.getQualifier());
-
-        Expression e2 = ExpressionFactory.expressionOfType(Expression.NOT_EQUAL_TO);
-        query.orQualifier(e2);
-        assertEquals(Expression.OR, query.getQualifier().getType());
-    }
-
-    @Test
-    public void testFetchLimit() throws Exception {
-        createArtistsDataSet();
-
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        query.setFetchLimit(7);
-
-        List<?> objects = context.performQuery(query);
-        assertNotNull(objects);
-        assertEquals(7, objects.size());
-    }
-
-    @Test
-    public void testFetchOffset() throws Exception {
-
-        createArtistsDataSet();
-
-        int totalRows = context.select(new SelectQuery<Artist>(Artist.class)).size();
-
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        query.addOrdering("db:" + Artist.ARTIST_ID_PK_COLUMN, SortOrder.ASCENDING);
-        query.setFetchOffset(5);
-        List<Artist> results = context.select(query);
-
-        assertEquals(totalRows - 5, results.size());
-        assertEquals("artist6", results.get(0).getArtistName());
-    }
-
-    @Test
-    public void testDbEntityRoot() throws Exception {
-
-        createArtistsDataSet();
-        DbEntity artistDbEntity = context.getEntityResolver().getDbEntity("ARTIST");
-
-        SelectQuery query = new SelectQuery(artistDbEntity);
-        List<?> results = context.performQuery(query);
-
-        assertEquals(20, results.size());
-        assertTrue(results.get(0) instanceof DataRow);
-    }
-
-    @Test
-    public void testFetchLimitWithOffset() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        query.addOrdering("db:" + Artist.ARTIST_ID_PK_COLUMN, SortOrder.ASCENDING);
-        query.setFetchOffset(15);
-        query.setFetchLimit(4);
-        List<Artist> results = context.select(query);
-
-        assertEquals(4, results.size());
-        assertEquals("artist16", results.get(0).getArtistName());
-    }
-
-    @Test
-    public void testFetchOffsetWithQualifier() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        query.setQualifier(Expression.fromString("db:ARTIST_ID > 3"));
-        query.setFetchOffset(5);
-
-        List<?> objects = context.performQuery(query);
-        int size = objects.size();
-
-        SelectQuery<Artist> sizeQ = new SelectQuery<Artist>(Artist.class);
-        sizeQ.setQualifier(Expression.fromString("db:ARTIST_ID > 3"));
-        List<?> objects1 = context.performQuery(sizeQ);
-        int sizeAll = objects1.size();
-        assertEquals(size, sizeAll - 5);
-    }
-
-    @Test
-    public void testFetchLimitWithQualifier() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        query.setQualifier(Expression.fromString("db:ARTIST_ID > 3"));
-        query.setFetchLimit(7);
-        List<?> objects = context.performQuery(query);
-        assertEquals(7, objects.size());
-    }
-
-    @Test
-    public void testSelectAllObjectsRootEntityName() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>("Artist");
-        List<?> objects = context.performQuery(query);
-        assertEquals(20, objects.size());
-    }
-
-    @Test
-    public void testSelectAllObjectsRootClass() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        List<?> objects = context.performQuery(query);
-        assertEquals(20, objects.size());
-    }
-
-    @Test
-    public void testSelectAllObjectsRootObjEntity() throws Exception {
-        createArtistsDataSet();
-        ObjEntity artistEntity = context.getEntityResolver().getObjEntity(Artist.class);
-        SelectQuery<Artist> query = new SelectQuery<Artist>(artistEntity);
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(20, objects.size());
-    }
-
-    @Test
-    public void testSelectLikeExactMatch() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.likeExp("artistName", "artist1");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-    }
-
-    @Test
-    public void testSelectNotLikeSingleWildcardMatch() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.notLikeExp("artistName", "artist11%");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(19, objects.size());
-    }
-
-    @Test
-    public void testSelectNotLikeIgnoreCaseSingleWildcardMatch() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.notLikeIgnoreCaseExp("artistName", "aRtIsT11%");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(19, objects.size());
-    }
-
-    @Test
-    public void testSelectLikeCaseSensitive() throws Exception {
-        if (!accessStackAdapter.supportsCaseSensitiveLike()) {
-            return;
-        }
-
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.likeExp("artistName", "aRtIsT%");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(0, objects.size());
-    }
-
-    @Test
-    public void testSelectLikeSingleWildcardMatch() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.likeExp("artistName", "artist11%");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-    }
-
-    @Test
-    public void testSelectLikeSingleWildcardMatchAndEscape() throws Exception {
-
-        createArtistsWildcardDataSet();
-
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        query.andQualifier(ExpressionFactory.likeExp("artistName", "=_%", '='));
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-    }
-    
-	@Test
-	public void testSelectLikeSingleWildcardMatchAndEscape_AndOtherCriteria() throws Exception
{
+	@Test
+	public void testSelectLike_WildcardMatchAndEscape_AndOtherCriteria() throws Exception {
 
 		createArtistsWildcardDataSet();
 
@@ -310,13 +313,14 @@ public class SelectQueryIT extends ServerCase {
 		List<?> objects = context.performQuery(query);
 		assertEquals(1, objects.size());
 	}
-	
+
 	@Test
-	public void testSelectLikeSingleWildcardMatchIgnoreCaseAndEscape_AndOtherCriteria() throws
Exception {
+	public void testSelectLike_WildcardMatchIgnoreCaseAndEscape_AndOtherCriteria() throws Exception
{
 
 		createArtistsWildcardDataSet();
 
-		// CAY-1978 - combining LIKE..ESCAPE with another clause generated bad SQL
+		// CAY-1978 - combining LIKE..ESCAPE with another clause generated bad
+		// SQL
 		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
 		query.andQualifier(ExpressionFactory.likeIgnoreCaseExp("artistName", "=_%", '='));
 		query.andQualifier(Artist.ARTIST_NAME.eq("_X"));
@@ -325,360 +329,360 @@ public class SelectQueryIT extends ServerCase {
 		assertEquals(1, objects.size());
 	}
 
-    @Test
-    public void testSelectLikeMultipleWildcardMatch() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.likeExp("artistName", "artist1%");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(11, objects.size());
-    }
-
-    /**
-     * Test how "like ignore case" works when using uppercase parameter.
-     */
-    @Test
-    public void testSelectLikeIgnoreCaseObjects1() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.likeIgnoreCaseExp("artistName", "ARTIST%");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(20, objects.size());
-    }
-
-    /** Test how "like ignore case" works when using lowercase parameter. */
-    @Test
-    public void testSelectLikeIgnoreCaseObjects2() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-        Expression qual = ExpressionFactory.likeIgnoreCaseExp("artistName", "artist%");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(20, objects.size());
-    }
-
-    @Test
-    public void testSelectIn() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = Expression.fromString("artistName in ('artist1', 'artist2')");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(2, objects.size());
-    }
-
-    @Test
-    public void testSelectParameterizedIn() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = Expression.fromString("artistName in $list");
-        query.setQualifier(qual);
-        query = query.queryWithParameters(Collections.singletonMap("list", new Object[] {
"artist1", "artist2" }));
-        List<?> objects = context.performQuery(query);
-        assertEquals(2, objects.size());
-    }
-
-    @Test
-    public void testSelectParameterizedEmptyIn() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = Expression.fromString("artistName in $list");
-        query.setQualifier(qual);
-        query = query.queryWithParameters(Collections.singletonMap("list", new Object[] {}));
-        List<?> objects = context.performQuery(query);
-        assertEquals(0, objects.size());
-    }
-
-    @Test
-    public void testSelectParameterizedEmptyNotIn() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = Expression.fromString("artistName not in $list");
-        query.setQualifier(qual);
-        query = query.queryWithParameters(Collections.singletonMap("list", new Object[] {}));
-        List<?> objects = context.performQuery(query);
-        assertEquals(20, objects.size());
-    }
-
-    @Test
-    public void testSelectEmptyIn() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = ExpressionFactory.inExp("artistName");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(0, objects.size());
-    }
-
-    @Test
-    public void testSelectEmptyNotIn() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = ExpressionFactory.notInExp("artistName");
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(20, objects.size());
-    }
-
-    @Test
-    public void testSelectBooleanTrue() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = ExpressionFactory.expTrue();
-        qual = qual.andExp(ExpressionFactory.matchExp("artistName", "artist1"));
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-    }
-
-    @Test
-    public void testSelectBooleanNotTrueOr() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = ExpressionFactory.expTrue();
-        qual = qual.notExp();
-        qual = qual.orExp(ExpressionFactory.matchExp("artistName", "artist1"));
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-    }
-
-    @Test
-    public void testSelectBooleanFalse() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = ExpressionFactory.expFalse();
-        qual = qual.andExp(ExpressionFactory.matchExp("artistName", "artist1"));
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(0, objects.size());
-    }
-
-    @Test
-    public void testSelectBooleanFalseOr() throws Exception {
-        createArtistsDataSet();
-        SelectQuery query = new SelectQuery(Artist.class);
-        Expression qual = ExpressionFactory.expFalse();
-        qual = qual.orExp(ExpressionFactory.matchExp("artistName", "artist1"));
-        query.setQualifier(qual);
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-    }
-
-    /**
-     * Tests that all queries specified in prefetch are executed in a more
-     * complex prefetch scenario.
-     */
-    @Test
-    public void testRouteWithPrefetches() {
-        EntityResolver resolver = context.getEntityResolver();
-        MockQueryRouter router = new MockQueryRouter();
-
-        SelectQuery<Artist> q = new SelectQuery<Artist>(Artist.class, ExpressionFactory.matchExp("artistName",
"a"));
-
-        q.route(router, resolver, null);
-        assertEquals(1, router.getQueryCount());
-
-        q.addPrefetch("paintingArray");
-        router.reset();
-        q.route(router, resolver, null);
-        assertEquals(2, router.getQueryCount());
-
-        q.addPrefetch("paintingArray.toGallery");
-        router.reset();
-        q.route(router, resolver, null);
-        assertEquals(3, router.getQueryCount());
-
-        q.addPrefetch("artistExhibitArray.toExhibit");
-        router.reset();
-        q.route(router, resolver, null);
-        assertEquals(4, router.getQueryCount());
-
-        q.removePrefetch("paintingArray");
-        router.reset();
-        q.route(router, resolver, null);
-        assertEquals(3, router.getQueryCount());
-    }
-
-    /**
-     * Tests that all queries specified in prefetch are executed in a more
-     * complex prefetch scenario with no reverse obj relationships.
-     */
-    @Test
-    public void testRouteQueryWithPrefetchesNoReverse() {
-
-        EntityResolver resolver = context.getEntityResolver();
-        ObjEntity paintingEntity = resolver.getObjEntity(Painting.class);
-        ObjEntity galleryEntity = resolver.getObjEntity(Gallery.class);
-        ObjEntity artistExhibitEntity = resolver.getObjEntity(ArtistExhibit.class);
-        ObjEntity exhibitEntity = resolver.getObjEntity(Exhibit.class);
-        ObjRelationship paintingToArtistRel = paintingEntity.getRelationship("toArtist");
-        paintingEntity.removeRelationship("toArtist");
-
-        ObjRelationship galleryToPaintingRel = galleryEntity.getRelationship("paintingArray");
-        galleryEntity.removeRelationship("paintingArray");
-
-        ObjRelationship artistExhibitToArtistRel = artistExhibitEntity.getRelationship("toArtist");
-        artistExhibitEntity.removeRelationship("toArtist");
-
-        ObjRelationship exhibitToArtistExhibitRel = exhibitEntity.getRelationship("artistExhibitArray");
-        exhibitEntity.removeRelationship("artistExhibitArray");
-
-        Expression e = ExpressionFactory.matchExp("artistName", "artist1");
-        SelectQuery<Artist> q = new SelectQuery<Artist>(Artist.class, e);
-        q.addPrefetch("paintingArray");
-        q.addPrefetch("paintingArray.toGallery");
-        q.addPrefetch("artistExhibitArray.toExhibit");
-
-        try {
-            MockQueryRouter router = new MockQueryRouter();
-            q.route(router, resolver, null);
-            assertEquals(4, router.getQueryCount());
-        } finally {
-            paintingEntity.addRelationship(paintingToArtistRel);
-            galleryEntity.addRelationship(galleryToPaintingRel);
-            artistExhibitEntity.addRelationship(artistExhibitToArtistRel);
-            exhibitEntity.addRelationship(exhibitToArtistExhibitRel);
-        }
-    }
-
-    /**
-     * Test prefetching with qualifier on the root query being the path to the
-     * prefetch.
-     */
-    @Test
-    public void testRouteQueryWithPrefetchesPrefetchExpressionPath() {
-
-        // find the painting not matching the artist (this is the case where
-        // such prefetch
-        // at least makes sense)
-        Expression exp = ExpressionFactory.noMatchExp("toArtist", new Object());
-
-        SelectQuery q = new SelectQuery(Painting.class, exp);
-        q.addPrefetch("toArtist");
-
-        // test how prefetches are resolved in this case - this was a stumbling
-        // block for
-        // a while
-        EntityResolver resolver = context.getEntityResolver();
-        MockQueryRouter router = new MockQueryRouter();
-        q.route(router, resolver, null);
-        assertEquals(2, router.getQueryCount());
-    }
-
-    @Test
-    public void testLeftJoinAndPrefetchToMany() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class, ExpressionFactory.matchExp(
-                "paintingArray+.toGallery", null));
-        query.addPrefetch("artistExhibitArray");
-        context.performQuery(query);
-    }
-
-    @Test
-    public void testLeftJoinAndPrefetchToOne() throws Exception {
-        createArtistsDataSet();
-        SelectQuery<Painting> query = new SelectQuery<Painting>(Painting.class,
ExpressionFactory.matchExp(
-                "toArtist+.artistName", null));
-        query.addPrefetch("toGallery");
-        context.select(query);
-    }
-
-    @Test
-    public void testSelect_MatchObject() {
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("a1");
-        Artist a2 = context.newObject(Artist.class);
-        a2.setArtistName("a2");
-        Artist a3 = context.newObject(Artist.class);
-        a3.setArtistName("a3");
-        context.commitChanges();
-
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
-
-        query.setQualifier(ExpressionFactory.matchExp(a2));
-        Object res = Cayenne.objectForQuery(context, query);// exception if >1
-                                                            // result
-        assertSame(res, a2);
-        assertTrue(query.getQualifier().match(res));
-
-        query.setQualifier(ExpressionFactory.matchAnyExp(a1, a3));
-        query.addOrdering("artistName", SortOrder.ASCENDING);
-        List<Artist> list = context.select(query);
-        assertEquals(list.size(), 2);
-        assertSame(list.get(0), a1);
-        assertSame(list.get(1), a3);
-        assertTrue(query.getQualifier().match(a1));
-        assertTrue(query.getQualifier().match(a3));
-
-        assertEquals(query.getQualifier(), ExpressionFactory.matchAnyExp(Arrays.asList(a1,
a3)));
-    }
-
-    @Test
-    public void testSelect_WithOrdering() {
-
-        Artist a1 = context.newObject(Artist.class);
-        a1.setArtistName("a1");
-        Artist a2 = context.newObject(Artist.class);
-        a2.setArtistName("a2");
-        Artist a3 = context.newObject(Artist.class);
-        a3.setArtistName("a3");
-        context.commitChanges();
-
-        List<Ordering> orderings = Arrays.asList(new Ordering("artistName", SortOrder.ASCENDING));
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class, null,
orderings);
-
-        List<Artist> list = context.select(query);
-        assertEquals(list.size(), 3);
-        assertSame(list.get(0), a1);
-        assertSame(list.get(1), a2);
-        assertSame(list.get(2), a3);
-    }
-
-    /**
-     * Tests INs with more than 1000 elements
-     */
-    @Test
-    public void testSelectLongIn() {
-        // not all adapters strip INs, so we just make sure query with such
-        // qualifier
-        // fires OK
-        Object[] numbers = new String[2009];
-        for (int i = 0; i < numbers.length; i++) {
-            numbers[i] = "" + i;
-        }
-
-        SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class,
-                ExpressionFactory.inExp("artistName", numbers));
-        context.performQuery(query);
-    }
-
-    @Test
-    public void testCacheOffsetAndLimit() throws Exception {
-        createArtistsDataSet();
-
-        SelectQuery<Artist> query1 = new SelectQuery<Artist>(Artist.class);
-        query1.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
-        query1.setFetchOffset(0);
-        query1.setFetchLimit(10);
-        context.performQuery(query1);
-
-        SelectQuery<Artist> query2 = new SelectQuery<Artist>(Artist.class);
-        query2.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
-        query2.setFetchOffset(10);
-        query2.setFetchLimit(10);
-        context.performQuery(query2);
-
-        SelectQuery<Artist> query3 = new SelectQuery<Artist>(Artist.class);
-        query3.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
-        query3.setFetchOffset(10);
-        query3.setFetchLimit(10);
-        context.performQuery(query3);
-
-        assertFalse(query1.metaData.getCacheKey().equals(query2.metaData.cacheKey));
-        assertEquals(query2.metaData.getCacheKey(), query3.metaData.getCacheKey());
-    }
+	@Test
+	public void testSelectLikeMultiple_WildcardMatch() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.likeExp("artistName", "artist1%");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(11, objects.size());
+	}
+
+	/**
+	 * Test how "like ignore case" works when using uppercase parameter.
+	 */
+	@Test
+	public void testSelectLikeIgnoreCaseObjects1() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.likeIgnoreCaseExp("artistName", "ARTIST%");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(20, objects.size());
+	}
+
+	/** Test how "like ignore case" works when using lowercase parameter. */
+	@Test
+	public void testSelectLikeIgnoreCaseObjects2() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+		Expression qual = ExpressionFactory.likeIgnoreCaseExp("artistName", "artist%");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(20, objects.size());
+	}
+
+	@Test
+	public void testSelectIn() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = Expression.fromString("artistName in ('artist1', 'artist2')");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(2, objects.size());
+	}
+
+	@Test
+	public void testSelectParameterizedIn() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = Expression.fromString("artistName in $list");
+		query.setQualifier(qual);
+		query = query.queryWithParameters(Collections.singletonMap("list", new Object[] { "artist1",
"artist2" }));
+		List<?> objects = context.performQuery(query);
+		assertEquals(2, objects.size());
+	}
+
+	@Test
+	public void testSelectParameterizedEmptyIn() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = Expression.fromString("artistName in $list");
+		query.setQualifier(qual);
+		query = query.queryWithParameters(Collections.singletonMap("list", new Object[] {}));
+		List<?> objects = context.performQuery(query);
+		assertEquals(0, objects.size());
+	}
+
+	@Test
+	public void testSelectParameterizedEmptyNotIn() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = Expression.fromString("artistName not in $list");
+		query.setQualifier(qual);
+		query = query.queryWithParameters(Collections.singletonMap("list", new Object[] {}));
+		List<?> objects = context.performQuery(query);
+		assertEquals(20, objects.size());
+	}
+
+	@Test
+	public void testSelectEmptyIn() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = ExpressionFactory.inExp("artistName");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(0, objects.size());
+	}
+
+	@Test
+	public void testSelectEmptyNotIn() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = ExpressionFactory.notInExp("artistName");
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(20, objects.size());
+	}
+
+	@Test
+	public void testSelectBooleanTrue() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = ExpressionFactory.expTrue();
+		qual = qual.andExp(ExpressionFactory.matchExp("artistName", "artist1"));
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+	}
+
+	@Test
+	public void testSelectBooleanNotTrueOr() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = ExpressionFactory.expTrue();
+		qual = qual.notExp();
+		qual = qual.orExp(ExpressionFactory.matchExp("artistName", "artist1"));
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+	}
+
+	@Test
+	public void testSelectBooleanFalse() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = ExpressionFactory.expFalse();
+		qual = qual.andExp(ExpressionFactory.matchExp("artistName", "artist1"));
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(0, objects.size());
+	}
+
+	@Test
+	public void testSelectBooleanFalseOr() throws Exception {
+		createArtistsDataSet();
+		SelectQuery query = new SelectQuery(Artist.class);
+		Expression qual = ExpressionFactory.expFalse();
+		qual = qual.orExp(ExpressionFactory.matchExp("artistName", "artist1"));
+		query.setQualifier(qual);
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+	}
+
+	/**
+	 * Tests that all queries specified in prefetch are executed in a more
+	 * complex prefetch scenario.
+	 */
+	@Test
+	public void testRouteWithPrefetches() {
+		EntityResolver resolver = context.getEntityResolver();
+		MockQueryRouter router = new MockQueryRouter();
+
+		SelectQuery<Artist> q = new SelectQuery<Artist>(Artist.class, ExpressionFactory.matchExp("artistName",
"a"));
+
+		q.route(router, resolver, null);
+		assertEquals(1, router.getQueryCount());
+
+		q.addPrefetch("paintingArray");
+		router.reset();
+		q.route(router, resolver, null);
+		assertEquals(2, router.getQueryCount());
+
+		q.addPrefetch("paintingArray.toGallery");
+		router.reset();
+		q.route(router, resolver, null);
+		assertEquals(3, router.getQueryCount());
+
+		q.addPrefetch("artistExhibitArray.toExhibit");
+		router.reset();
+		q.route(router, resolver, null);
+		assertEquals(4, router.getQueryCount());
+
+		q.removePrefetch("paintingArray");
+		router.reset();
+		q.route(router, resolver, null);
+		assertEquals(3, router.getQueryCount());
+	}
+
+	/**
+	 * Tests that all queries specified in prefetch are executed in a more
+	 * complex prefetch scenario with no reverse obj relationships.
+	 */
+	@Test
+	public void testRouteQueryWithPrefetchesNoReverse() {
+
+		EntityResolver resolver = context.getEntityResolver();
+		ObjEntity paintingEntity = resolver.getObjEntity(Painting.class);
+		ObjEntity galleryEntity = resolver.getObjEntity(Gallery.class);
+		ObjEntity artistExhibitEntity = resolver.getObjEntity(ArtistExhibit.class);
+		ObjEntity exhibitEntity = resolver.getObjEntity(Exhibit.class);
+		ObjRelationship paintingToArtistRel = paintingEntity.getRelationship("toArtist");
+		paintingEntity.removeRelationship("toArtist");
+
+		ObjRelationship galleryToPaintingRel = galleryEntity.getRelationship("paintingArray");
+		galleryEntity.removeRelationship("paintingArray");
+
+		ObjRelationship artistExhibitToArtistRel = artistExhibitEntity.getRelationship("toArtist");
+		artistExhibitEntity.removeRelationship("toArtist");
+
+		ObjRelationship exhibitToArtistExhibitRel = exhibitEntity.getRelationship("artistExhibitArray");
+		exhibitEntity.removeRelationship("artistExhibitArray");
+
+		Expression e = ExpressionFactory.matchExp("artistName", "artist1");
+		SelectQuery<Artist> q = new SelectQuery<Artist>(Artist.class, e);
+		q.addPrefetch("paintingArray");
+		q.addPrefetch("paintingArray.toGallery");
+		q.addPrefetch("artistExhibitArray.toExhibit");
+
+		try {
+			MockQueryRouter router = new MockQueryRouter();
+			q.route(router, resolver, null);
+			assertEquals(4, router.getQueryCount());
+		} finally {
+			paintingEntity.addRelationship(paintingToArtistRel);
+			galleryEntity.addRelationship(galleryToPaintingRel);
+			artistExhibitEntity.addRelationship(artistExhibitToArtistRel);
+			exhibitEntity.addRelationship(exhibitToArtistExhibitRel);
+		}
+	}
+
+	/**
+	 * Test prefetching with qualifier on the root query being the path to the
+	 * prefetch.
+	 */
+	@Test
+	public void testRouteQueryWithPrefetchesPrefetchExpressionPath() {
+
+		// find the painting not matching the artist (this is the case where
+		// such prefetch
+		// at least makes sense)
+		Expression exp = ExpressionFactory.noMatchExp("toArtist", new Object());
+
+		SelectQuery q = new SelectQuery(Painting.class, exp);
+		q.addPrefetch("toArtist");
+
+		// test how prefetches are resolved in this case - this was a stumbling
+		// block for
+		// a while
+		EntityResolver resolver = context.getEntityResolver();
+		MockQueryRouter router = new MockQueryRouter();
+		q.route(router, resolver, null);
+		assertEquals(2, router.getQueryCount());
+	}
+
+	@Test
+	public void testLeftJoinAndPrefetchToMany() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class, ExpressionFactory.matchExp(
+				"paintingArray+.toGallery", null));
+		query.addPrefetch("artistExhibitArray");
+		context.performQuery(query);
+	}
+
+	@Test
+	public void testLeftJoinAndPrefetchToOne() throws Exception {
+		createArtistsDataSet();
+		SelectQuery<Painting> query = new SelectQuery<Painting>(Painting.class, ExpressionFactory.matchExp(
+				"toArtist+.artistName", null));
+		query.addPrefetch("toGallery");
+		context.select(query);
+	}
+
+	@Test
+	public void testSelect_MatchObject() {
+
+		Artist a1 = context.newObject(Artist.class);
+		a1.setArtistName("a1");
+		Artist a2 = context.newObject(Artist.class);
+		a2.setArtistName("a2");
+		Artist a3 = context.newObject(Artist.class);
+		a3.setArtistName("a3");
+		context.commitChanges();
+
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class);
+
+		query.setQualifier(ExpressionFactory.matchExp(a2));
+		Object res = Cayenne.objectForQuery(context, query);// exception if >1
+															// result
+		assertSame(res, a2);
+		assertTrue(query.getQualifier().match(res));
+
+		query.setQualifier(ExpressionFactory.matchAnyExp(a1, a3));
+		query.addOrdering("artistName", SortOrder.ASCENDING);
+		List<Artist> list = context.select(query);
+		assertEquals(list.size(), 2);
+		assertSame(list.get(0), a1);
+		assertSame(list.get(1), a3);
+		assertTrue(query.getQualifier().match(a1));
+		assertTrue(query.getQualifier().match(a3));
+
+		assertEquals(query.getQualifier(), ExpressionFactory.matchAnyExp(Arrays.asList(a1, a3)));
+	}
+
+	@Test
+	public void testSelect_WithOrdering() {
+
+		Artist a1 = context.newObject(Artist.class);
+		a1.setArtistName("a1");
+		Artist a2 = context.newObject(Artist.class);
+		a2.setArtistName("a2");
+		Artist a3 = context.newObject(Artist.class);
+		a3.setArtistName("a3");
+		context.commitChanges();
+
+		List<Ordering> orderings = Arrays.asList(new Ordering("artistName", SortOrder.ASCENDING));
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class, null, orderings);
+
+		List<Artist> list = context.select(query);
+		assertEquals(list.size(), 3);
+		assertSame(list.get(0), a1);
+		assertSame(list.get(1), a2);
+		assertSame(list.get(2), a3);
+	}
+
+	/**
+	 * Tests INs with more than 1000 elements
+	 */
+	@Test
+	public void testSelectLongIn() {
+		// not all adapters strip INs, so we just make sure query with such
+		// qualifier
+		// fires OK
+		Object[] numbers = new String[2009];
+		for (int i = 0; i < numbers.length; i++) {
+			numbers[i] = "" + i;
+		}
+
+		SelectQuery<Artist> query = new SelectQuery<Artist>(Artist.class,
+				ExpressionFactory.inExp("artistName", numbers));
+		context.performQuery(query);
+	}
+
+	@Test
+	public void testCacheOffsetAndLimit() throws Exception {
+		createArtistsDataSet();
+
+		SelectQuery<Artist> query1 = new SelectQuery<Artist>(Artist.class);
+		query1.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+		query1.setFetchOffset(0);
+		query1.setFetchLimit(10);
+		context.performQuery(query1);
+
+		SelectQuery<Artist> query2 = new SelectQuery<Artist>(Artist.class);
+		query2.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+		query2.setFetchOffset(10);
+		query2.setFetchLimit(10);
+		context.performQuery(query2);
+
+		SelectQuery<Artist> query3 = new SelectQuery<Artist>(Artist.class);
+		query3.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+		query3.setFetchOffset(10);
+		query3.setFetchLimit(10);
+		context.performQuery(query3);
+
+		assertFalse(query1.metaData.getCacheKey().equals(query2.metaData.cacheKey));
+		assertEquals(query2.metaData.getCacheKey(), query3.metaData.getCacheKey());
+	}
 }


Mime
View raw message