cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [06/17] cayenne git commit: CAY-2026 Java 7
Date Sat, 12 Sep 2015 10:02:34 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateIT.java
index dd7f582..d55111c 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateIT.java
@@ -53,534 +53,497 @@ import static org.junit.Assert.assertTrue;
 @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
 public class DataContextSQLTemplateIT extends ServerCase {
 
-    @Inject
-    private ServerRuntime runtime;
-    
-    @Inject
-    protected DataContext context;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    @Inject
-    protected SQLTemplateCustomizer sqlTemplateCustomizer;
-
-    protected TableHelper tPainting;
-    protected TableHelper tArtist;
-
-    @Before
-    public void setUp() throws Exception {
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tPainting = new TableHelper(dbHelper, "PAINTING");
-        tPainting.setColumns(
-                "PAINTING_ID",
-                "PAINTING_TITLE",
-                "ARTIST_ID",
-                "ESTIMATED_PRICE").setColumnTypes(
-                Types.INTEGER,
-                Types.VARCHAR,
-                Types.BIGINT,
-                Types.DECIMAL);
-    }
-
-    protected void createFourArtists() throws Exception {
-        tArtist.insert(11, "artist2");
-        tArtist.insert(101, "artist3");
-        tArtist.insert(201, "artist4");
-        tArtist.insert(3001, "artist5");
-    }
-
-    protected void createFourArtistsAndThreePaintingsDataSet() throws Exception {
-        createFourArtists();
-
-        tPainting.insert(6, "p_artist3", 11, 1000);
-        tPainting.insert(7, "p_artist2", 101, 2000);
-        tPainting.insert(8, "p_artist4", null, 3000);
-    }
-
-    @Test
-    public void testSQLResultSetMappingMixed() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
-
-        String sql = "SELECT #result('t0.ARTIST_ID' 'long' 'X'), #result('t0.ARTIST_NAME' 'String' 'Y'), #result('t0.DATE_OF_BIRTH' 'Date' 'Z'), #result('count(t1.PAINTING_ID)' 'int' 'C') "
-                + "FROM ARTIST t0 LEFT JOIN PAINTING t1 ON (t0.ARTIST_ID = t1.ARTIST_ID) "
-                + "GROUP BY t0.ARTIST_ID, t0.ARTIST_NAME, t0.DATE_OF_BIRTH "
-                + "ORDER BY t0.ARTIST_ID";
-
-        DataMap map = context.getEntityResolver().getDataMap("testmap");
-        SQLTemplate query = new SQLTemplate(map, sql, false);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-
-        EntityResult artistResult = new EntityResult(Artist.class);
-        artistResult.addDbField(Artist.ARTIST_ID_PK_COLUMN, "X");
-        artistResult.addObjectField(Artist.ARTIST_NAME_PROPERTY, "Y");
-        artistResult.addObjectField(Artist.DATE_OF_BIRTH_PROPERTY, "Z");
-
-        SQLResult rsMap = new SQLResult();
-        rsMap.addEntityResult(artistResult);
-        rsMap.addColumnResult("C");
-        query.setResult(rsMap);
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(4, objects.size());
-
-        Object o1 = objects.get(0);
-        assertTrue("Expected Object[]: " + o1, o1 instanceof Object[]);
-        Object[] array1 = (Object[]) o1;
-        assertEquals(2, array1.length);
-        Object[] array2 = (Object[]) objects.get(1);
-        assertEquals(2, array2.length);
-        Object[] array3 = (Object[]) objects.get(2);
-        assertEquals(2, array3.length);
-        Object[] array4 = (Object[]) objects.get(3);
-        assertEquals(2, array3.length);
-
-        assertEquals(new Integer(1), array1[1]);
-        assertEquals(new Integer(1), array2[1]);
-        assertEquals(new Integer(0), array3[1]);
-        assertEquals(new Integer(0), array4[1]);
-        assertTrue("Unexpected DataObject: " + array1[0], array1[0] instanceof Artist);
-    }
-
-    @Test
-    public void testRootless_DataNodeName() throws Exception {
-        createFourArtists();
-        
-        SQLTemplate query = new SQLTemplate("SELECT * FROM ARTIST", true);
-        query.setDataNodeName("testmap");
-        assertEquals(4, context.performQuery(query).size());
-    }
-
-    @Test
-    public void testRootless_DefaultDataNode() throws Exception {
-        createFourArtists();
-        SQLTemplate query = new SQLTemplate("SELECT * FROM ARTIST", true);
-        assertEquals(4, context.performQuery(query).size());
-    }
-
-    @Test
-    public void testSQLResultSetMappingScalar() throws Exception {
-        createFourArtists();
-
-        String sql = "SELECT count(1) AS X FROM ARTIST";
-
-        DataMap map = context.getEntityResolver().getDataMap("testmap");
-        SQLTemplate query = new SQLTemplate(map, sql, false);
-        query.setTemplate(
-                FrontBaseAdapter.class.getName(),
-                "SELECT COUNT(ARTIST_ID) X FROM ARTIST");
-        query.setTemplate(
-                OpenBaseAdapter.class.getName(),
-                "SELECT COUNT(ARTIST_ID) X FROM ARTIST");
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-
-        SQLResult rsMap = new SQLResult();
-        rsMap.addColumnResult("X");
-        query.setResult(rsMap);
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-
-        Object o = objects.get(0);
-        assertTrue("Expected Number: " + o, o instanceof Number);
-        assertEquals(4, ((Number) o).intValue());
-    }
-
-    @Test
-    public void testSQLResultSetMappingScalarArray() throws Exception {
-        createFourArtists();
-
-        String sql = "SELECT count(1) AS X, 77 AS Y FROM ARTIST";
-
-        DataMap map = context.getEntityResolver().getDataMap("testmap");
-        SQLTemplate query = new SQLTemplate(map, sql, false);
-        query.setTemplate(
-                FrontBaseAdapter.class.getName(),
-                "SELECT COUNT(ARTIST_ID) X, 77 Y FROM ARTIST GROUP BY Y");
-        query.setTemplate(
-                OpenBaseAdapter.class.getName(),
-                "SELECT COUNT(ARTIST_ID) X, 77 Y FROM ARTIST GROUP BY 77");
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-
-        SQLResult rsMap = new SQLResult();
-        rsMap.addColumnResult("X");
-        rsMap.addColumnResult("Y");
-        query.setResult(rsMap);
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-
-        Object o = objects.get(0);
-        assertTrue(o instanceof Object[]);
-
-        Object[] row = (Object[]) o;
-        assertEquals(2, row.length);
-
-        assertEquals(4, ((Number) row[0]).intValue());
-        assertEquals(77, ((Number) row[1]).intValue());
-    }
-
-    @Test
-    public void testColumnNamesCapitalization() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
-
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Artist.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.LOWER);
-        query.setFetchingDataRows(true);
-
-        List<DataRow> rows = context.performQuery(query);
-
-        DataRow row1 = rows.get(0);
-        assertFalse(row1.containsKey("ARTIST_ID"));
-        assertTrue(row1.containsKey("artist_id"));
-
-        DataRow row2 = rows.get(1);
-        assertFalse(row2.containsKey("ARTIST_ID"));
-        assertTrue(row2.containsKey("artist_id"));
+	@Inject
+	private ServerRuntime runtime;
+
+	@Inject
+	protected DataContext context;
+
+	@Inject
+	protected DBHelper dbHelper;
+
+	@Inject
+	protected SQLTemplateCustomizer sqlTemplateCustomizer;
+
+	protected TableHelper tPainting;
+	protected TableHelper tArtist;
+
+	@Before
+	public void setUp() throws Exception {
+		tArtist = new TableHelper(dbHelper, "ARTIST");
+		tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+
+		tPainting = new TableHelper(dbHelper, "PAINTING");
+		tPainting.setColumns("PAINTING_ID", "PAINTING_TITLE", "ARTIST_ID", "ESTIMATED_PRICE").setColumnTypes(
+				Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.DECIMAL);
+	}
+
+	protected void createFourArtists() throws Exception {
+		tArtist.insert(11, "artist2");
+		tArtist.insert(101, "artist3");
+		tArtist.insert(201, "artist4");
+		tArtist.insert(3001, "artist5");
+	}
+
+	protected void createFourArtistsAndThreePaintingsDataSet() throws Exception {
+		createFourArtists();
+
+		tPainting.insert(6, "p_artist3", 11, 1000);
+		tPainting.insert(7, "p_artist2", 101, 2000);
+		tPainting.insert(8, "p_artist4", null, 3000);
+	}
+
+	@Test
+	public void testSQLResultSetMappingMixed() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
+
+		String sql = "SELECT #result('t0.ARTIST_ID' 'long' 'X'), #result('t0.ARTIST_NAME' 'String' 'Y'), #result('t0.DATE_OF_BIRTH' 'Date' 'Z'), #result('count(t1.PAINTING_ID)' 'int' 'C') "
+				+ "FROM ARTIST t0 LEFT JOIN PAINTING t1 ON (t0.ARTIST_ID = t1.ARTIST_ID) "
+				+ "GROUP BY t0.ARTIST_ID, t0.ARTIST_NAME, t0.DATE_OF_BIRTH " + "ORDER BY t0.ARTIST_ID";
+
+		DataMap map = context.getEntityResolver().getDataMap("testmap");
+		SQLTemplate query = new SQLTemplate(map, sql, false);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+
+		EntityResult artistResult = new EntityResult(Artist.class);
+		artistResult.addDbField(Artist.ARTIST_ID_PK_COLUMN, "X");
+		artistResult.addObjectField(Artist.ARTIST_NAME_PROPERTY, "Y");
+		artistResult.addObjectField(Artist.DATE_OF_BIRTH_PROPERTY, "Z");
+
+		SQLResult rsMap = new SQLResult();
+		rsMap.addEntityResult(artistResult);
+		rsMap.addColumnResult("C");
+		query.setResult(rsMap);
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(4, objects.size());
+
+		Object o1 = objects.get(0);
+		assertTrue("Expected Object[]: " + o1, o1 instanceof Object[]);
+		Object[] array1 = (Object[]) o1;
+		assertEquals(2, array1.length);
+		Object[] array2 = (Object[]) objects.get(1);
+		assertEquals(2, array2.length);
+		Object[] array3 = (Object[]) objects.get(2);
+		assertEquals(2, array3.length);
+		Object[] array4 = (Object[]) objects.get(3);
+		assertEquals(2, array3.length);
+
+		assertEquals(new Integer(1), array1[1]);
+		assertEquals(new Integer(1), array2[1]);
+		assertEquals(new Integer(0), array3[1]);
+		assertEquals(new Integer(0), array4[1]);
+		assertTrue("Unexpected DataObject: " + array1[0], array1[0] instanceof Artist);
+	}
+
+	@Test
+	public void testRootless_DataNodeName() throws Exception {
+		createFourArtists();
+
+		SQLTemplate query = new SQLTemplate("SELECT * FROM ARTIST", true);
+		query.setDataNodeName("testmap");
+		assertEquals(4, context.performQuery(query).size());
+	}
+
+	@Test
+	public void testRootless_DefaultDataNode() throws Exception {
+		createFourArtists();
+		SQLTemplate query = new SQLTemplate("SELECT * FROM ARTIST", true);
+		assertEquals(4, context.performQuery(query).size());
+	}
 
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+	@Test
+	public void testSQLResultSetMappingScalar() throws Exception {
+		createFourArtists();
+
+		String sql = "SELECT count(1) AS X FROM ARTIST";
+
+		DataMap map = context.getEntityResolver().getDataMap("testmap");
+		SQLTemplate query = new SQLTemplate(map, sql, false);
+		query.setTemplate(FrontBaseAdapter.class.getName(), "SELECT COUNT(ARTIST_ID) X FROM ARTIST");
+		query.setTemplate(OpenBaseAdapter.class.getName(), "SELECT COUNT(ARTIST_ID) X FROM ARTIST");
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+
+		SQLResult rsMap = new SQLResult();
+		rsMap.addColumnResult("X");
+		query.setResult(rsMap);
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+
+		Object o = objects.get(0);
+		assertTrue("Expected Number: " + o, o instanceof Number);
+		assertEquals(4, ((Number) o).intValue());
+	}
+
+	@Test
+	public void testSQLResultSetMappingScalarArray() throws Exception {
+		createFourArtists();
+
+		String sql = "SELECT count(1) AS X, 77 AS Y FROM ARTIST";
 
-        List<DataRow> rowsUpper = context.performQuery(query);
-
-        DataRow row3 = rowsUpper.get(0);
-        assertFalse(row3.containsKey("artist_id"));
-        assertTrue(row3.containsKey("ARTIST_ID"));
+		DataMap map = context.getEntityResolver().getDataMap("testmap");
+		SQLTemplate query = new SQLTemplate(map, sql, false);
+		query.setTemplate(FrontBaseAdapter.class.getName(), "SELECT COUNT(ARTIST_ID) X, 77 Y FROM ARTIST GROUP BY Y");
+		query.setTemplate(OpenBaseAdapter.class.getName(), "SELECT COUNT(ARTIST_ID) X, 77 Y FROM ARTIST GROUP BY 77");
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
-        DataRow row4 = rowsUpper.get(1);
-        assertFalse(row4.containsKey("artist_id"));
-        assertTrue(row4.containsKey("ARTIST_ID"));
-    }
+		SQLResult rsMap = new SQLResult();
+		rsMap.addColumnResult("X");
+		rsMap.addColumnResult("Y");
+		query.setResult(rsMap);
 
-    @Test
-    public void testFetchDataRows() throws Exception {
-        createFourArtists();
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
 
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = new SQLTemplate(Artist.class, template);
+		Object o = objects.get(0);
+		assertTrue(o instanceof Object[]);
 
-        sqlTemplateCustomizer.updateSQLTemplate(query);
+		Object[] row = (Object[]) o;
+		assertEquals(2, row.length);
 
-        query.setFetchingDataRows(true);
+		assertEquals(4, ((Number) row[0]).intValue());
+		assertEquals(77, ((Number) row[1]).intValue());
+	}
 
-        List<DataRow> rows = context.performQuery(query);
-        assertEquals(4, rows.size());
+	@Test
+	public void testColumnNamesCapitalization() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
 
-        DataRow row2 = rows.get(1);
-        assertEquals(3, row2.size());
-        Object id = row2.get("ARTIST_ID");
-        assertEquals(new Integer(101), new Integer(id.toString()));
-    }
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = new SQLTemplate(Artist.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.LOWER);
+		query.setFetchingDataRows(true);
 
-    @Test
-    public void testFetchObjects() throws Exception {
-        createFourArtists();
+		List<DataRow> rows = context.performQuery(query);
 
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(
-                Artist.class,
-                template);
+		DataRow row1 = rows.get(0);
+		assertFalse(row1.containsKey("ARTIST_ID"));
+		assertTrue(row1.containsKey("artist_id"));
 
-        query.setFetchingDataRows(false);
+		DataRow row2 = rows.get(1);
+		assertFalse(row2.containsKey("ARTIST_ID"));
+		assertTrue(row2.containsKey("artist_id"));
 
-        List<?> objects = context.performQuery(query);
-        assertEquals(4, objects.size());
-        assertTrue(objects.get(1) instanceof Artist);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
-        Artist artist2 = (Artist) objects.get(1);
-        assertEquals("artist3", artist2.getArtistName());
-    }
+		List<DataRow> rowsUpper = context.performQuery(query);
 
-    @Test
-    public void testBindObjectEqualShort() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
+		DataRow row3 = rowsUpper.get(0);
+		assertFalse(row3.containsKey("artist_id"));
+		assertTrue(row3.containsKey("ARTIST_ID"));
 
-        Artist a = Cayenne.objectForPK(context, Artist.class, 101);
+		DataRow row4 = rowsUpper.get(1);
+		assertFalse(row4.containsKey("artist_id"));
+		assertTrue(row4.containsKey("ARTIST_ID"));
+	}
 
-        String template = "SELECT * FROM PAINTING "
-                + "WHERE #bindObjectEqual($a) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("a", a));
+	@Test
+	public void testFetchDataRows() throws Exception {
+		createFourArtists();
 
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = new SQLTemplate(Artist.class, template);
 
-        Painting p = (Painting) objects.get(0);
-        assertEquals(7, Cayenne.intPKForObject(p));
-    }
+		sqlTemplateCustomizer.updateSQLTemplate(query);
 
-    @Test
-    public void testBindObjectNotEqualShort() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
+		query.setFetchingDataRows(true);
 
-        Artist a = Cayenne.objectForPK(context, Artist.class, 101);
+		List<DataRow> rows = context.performQuery(query);
+		assertEquals(4, rows.size());
 
-        String template = "SELECT * FROM PAINTING "
-                + "WHERE #bindObjectNotEqual($a) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("a", a));
+		DataRow row2 = rows.get(1);
+		assertEquals(3, row2.size());
+		Object id = row2.get("ARTIST_ID");
+		assertEquals(new Integer(101), new Integer(id.toString()));
+	}
 
-        List<?> objects = context.performQuery(query);
+	@Test
+	public void testFetchObjects() throws Exception {
+		createFourArtists();
 
-        // null comparison is unpredictable across DB's ... some would return true on null
-        // <> value, some - false
-        assertTrue(objects.size() == 1 || objects.size() == 2);
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(Artist.class, template);
 
-        Painting p = (Painting) objects.get(0);
-        assertEquals(6, Cayenne.intPKForObject(p));
-    }
+		query.setFetchingDataRows(false);
 
-    @Test
-    public void testBindObjectEqualFull() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
+		List<?> objects = context.performQuery(query);
+		assertEquals(4, objects.size());
+		assertTrue(objects.get(1) instanceof Artist);
 
-        Artist a = Cayenne.objectForPK(context, Artist.class, 101);
+		Artist artist2 = (Artist) objects.get(1);
+		assertEquals("artist3", artist2.getArtistName());
+	}
 
-        String template = "SELECT * FROM PAINTING t0"
-                + " WHERE #bindObjectEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("a", a));
+	@Test
+	public void testBindObjectEqualShort() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
 
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
+		Artist a = Cayenne.objectForPK(context, Artist.class, 101);
 
-        Painting p = (Painting) objects.get(0);
-        assertEquals(7, Cayenne.intPKForObject(p));
-    }
+		String template = "SELECT * FROM PAINTING " + "WHERE #bindObjectEqual($a) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("a", a));
 
-    @Test
-    public void testBindObjectEqualFullNonArray() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
 
-        Artist a = Cayenne.objectForPK(context, Artist.class, 101);
+		Painting p = (Painting) objects.get(0);
+		assertEquals(7, Cayenne.intPKForObject(p));
+	}
 
-        String template = "SELECT * FROM PAINTING t0"
-                + " WHERE #bindObjectEqual($a 't0.ARTIST_ID' 'ARTIST_ID' ) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("a", a));
+	@Test
+	public void testBindObjectNotEqualShort() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
 
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
+		Artist a = Cayenne.objectForPK(context, Artist.class, 101);
 
-        Painting p = (Painting) objects.get(0);
-        assertEquals(7, Cayenne.intPKForObject(p));
-    }
+		String template = "SELECT * FROM PAINTING " + "WHERE #bindObjectNotEqual($a) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("a", a));
 
-    @Test
-    public void testBindObjectEqualNull() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
+		List<?> objects = context.performQuery(query);
 
-        String template = "SELECT * FROM PAINTING t0"
-                + " WHERE #bindObjectEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("a", null));
+		// null comparison is unpredictable across DB's ... some would return
+		// true on null
+		// <> value, some - false
+		assertTrue(objects.size() == 1 || objects.size() == 2);
 
-        List<?> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
+		Painting p = (Painting) objects.get(0);
+		assertEquals(6, Cayenne.intPKForObject(p));
+	}
 
-        Painting p = (Painting) objects.get(0);
-        assertEquals(8, Cayenne.intPKForObject(p));
-    }
+	@Test
+	public void testBindObjectEqualFull() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
 
-    @Test
-    public void testBindObjectNotEqualFull() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
-
-        Artist a = Cayenne.objectForPK(context, Artist.class, 101);
-
-        String template = "SELECT * FROM PAINTING t0"
-                + " WHERE #bindObjectNotEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("a", a));
-
-        List<?> objects = context.performQuery(query);
-        // null comparison is unpredictable across DB's ... some would return true on null
-        // <> value, some - false
-        assertTrue(objects.size() == 1 || objects.size() == 2);
-
-        Painting p = (Painting) objects.get(0);
-        assertEquals(6, Cayenne.intPKForObject(p));
-    }
-
-    @Test
-    public void testBindObjectNotEqualNull() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
-
-        String template = "SELECT * FROM PAINTING t0"
-                + " WHERE #bindObjectNotEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("a", null));
-
-        List<Painting> objects = context.performQuery(query);
-        assertEquals(2, objects.size());
+		Artist a = Cayenne.objectForPK(context, Artist.class, 101);
 
-        Painting p1 = objects.get(0);
-        assertEquals(6, Cayenne.intPKForObject(p1));
+		String template = "SELECT * FROM PAINTING t0"
+				+ " WHERE #bindObjectEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("a", a));
 
-        Painting p2 = objects.get(1);
-        assertEquals(7, Cayenne.intPKForObject(p2));
-    }
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
 
-    @Test
-    public void testBindEqualNull() throws Exception {
-        createFourArtistsAndThreePaintingsDataSet();
-
-        String template = "SELECT * FROM PAINTING t0"
-                + " WHERE t0.ARTIST_ID #bindEqual($id) ORDER BY PAINTING_ID";
-        SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
-        query.setParameters(Collections.singletonMap("id", null));
-
-        List<Painting> objects = context.performQuery(query);
-        assertEquals(1, objects.size());
-
-        Painting p = objects.get(0);
-        assertEquals(8, Cayenne.intPKForObject(p));
-    }
-
-    @Test
-    public void testFetchLimit() throws Exception {
-        createFourArtists();
-
-        int fetchLimit = 2;
-
-        // sanity check
-        assertTrue(fetchLimit < 4);
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(
-                Artist.class,
-                template);
-        query.setFetchLimit(fetchLimit);
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(fetchLimit, objects.size());
-        assertTrue(objects.get(0) instanceof Artist);
-    }
-
-    @Test
-    public void testFetchOffset() throws Exception {
-        createFourArtists();
-
-        int fetchOffset = 2;
-
-        // sanity check
-        assertTrue(fetchOffset < 4);
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(
-                Artist.class,
-                template);
-        query.setFetchOffset(fetchOffset);
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(4 - fetchOffset, objects.size());
-        assertTrue(objects.get(0) instanceof Artist);
-    }
-
-    @Test
-    public void testFetchOffsetFetchLimit() throws Exception {
-        createFourArtists();
-
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(
-                Artist.class,
-                template);
-        query.setFetchOffset(1);
-        query.setFetchLimit(2);
-
-        List<?> objects = context.performQuery(query);
-        assertEquals(2, objects.size());
-        assertTrue(objects.get(0) instanceof Artist);
-    }
-
-    @Test
-    public void testPageSize() throws Exception {
-        createFourArtists();
-
-        int pageSize = 3;
-
-        // sanity check
-        assertTrue(pageSize < 4);
-
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(
-                Artist.class,
-                template);
-
-        query.setPageSize(pageSize);
-
-        List<?> objects = context.performQuery(query);
-
-        assertEquals(4, objects.size());
-        assertTrue(objects.get(0) instanceof Artist);
-
-        assertTrue(objects instanceof IncrementalFaultList<?>);
-        IncrementalFaultList<?> pagedList = (IncrementalFaultList<?>) objects;
-        assertEquals(4 - pageSize, pagedList.getUnfetchedObjects());
-
-        // check if we can resolve subsequent pages
-        Artist artist = (Artist) objects.get(pageSize);
-
-        int expectUnresolved = 4 - pageSize - pageSize;
-        if (expectUnresolved < 0) {
-            expectUnresolved = 0;
-        }
-        assertEquals(expectUnresolved, pagedList.getUnfetchedObjects());
-        assertEquals("artist" + (pageSize + 2), artist.getArtistName());
-    }
-
-    @Test
-    public void testIteratedQuery() throws Exception {
-        createFourArtists();
-
-        String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
-        SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(
-                Artist.class,
-                template);
-
-        ResultIterator it = context.performIteratedQuery(query);
-
-        try {
-            long i = 0;
-
-            while (it.hasNextRow()) {
-                i++;
-
-                DataRow row = (DataRow) it.nextRow();
-                assertEquals(3, row.size());
-                assertEquals("artist" + (1 + i), row.get("ARTIST_NAME"));
-            }
-
-            assertEquals(4, i);
-        }
-        finally {
-            it.close();
-        }
-    }
-
-    @Test
-    public void testQueryWithLineBreakAfterMacro() throws Exception {
-        createFourArtists();
-
-        // see CAY-726 for details
-        String template = "SELECT #result('count(*)' 'int' 'X')"
-                + System.getProperty("line.separator")
-                + "FROM ARTIST";
-        SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(
-                Artist.class,
-                template);
-        query.setFetchingDataRows(true);
-
-        List<?> result = context.performQuery(query);
-
-        assertEquals(4, ((DataRow) result.get(0)).get("X"));
-    }
+		Painting p = (Painting) objects.get(0);
+		assertEquals(7, Cayenne.intPKForObject(p));
+	}
+
+	@Test
+	public void testBindObjectEqualFullNonArray() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
+
+		Artist a = Cayenne.objectForPK(context, Artist.class, 101);
+
+		String template = "SELECT * FROM PAINTING t0"
+				+ " WHERE #bindObjectEqual($a 't0.ARTIST_ID' 'ARTIST_ID' ) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("a", a));
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+
+		Painting p = (Painting) objects.get(0);
+		assertEquals(7, Cayenne.intPKForObject(p));
+	}
+
+	@Test
+	public void testBindObjectEqualNull() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
+
+		String template = "SELECT * FROM PAINTING t0"
+				+ " WHERE #bindObjectEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("a", null));
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+
+		Painting p = (Painting) objects.get(0);
+		assertEquals(8, Cayenne.intPKForObject(p));
+	}
+
+	@Test
+	public void testBindObjectNotEqualFull() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
+
+		Artist a = Cayenne.objectForPK(context, Artist.class, 101);
+
+		String template = "SELECT * FROM PAINTING t0"
+				+ " WHERE #bindObjectNotEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("a", a));
+
+		List<?> objects = context.performQuery(query);
+		// null comparison is unpredictable across DB's ... some would return
+		// true on null
+		// <> value, some - false
+		assertTrue(objects.size() == 1 || objects.size() == 2);
+
+		Painting p = (Painting) objects.get(0);
+		assertEquals(6, Cayenne.intPKForObject(p));
+	}
+
+	@Test
+	public void testBindObjectNotEqualNull() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
+
+		String template = "SELECT * FROM PAINTING t0"
+				+ " WHERE #bindObjectNotEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("a", null));
+
+		List<Painting> objects = context.performQuery(query);
+		assertEquals(2, objects.size());
+
+		Painting p1 = objects.get(0);
+		assertEquals(6, Cayenne.intPKForObject(p1));
+
+		Painting p2 = objects.get(1);
+		assertEquals(7, Cayenne.intPKForObject(p2));
+	}
+
+	@Test
+	public void testBindEqualNull() throws Exception {
+		createFourArtistsAndThreePaintingsDataSet();
+
+		String template = "SELECT * FROM PAINTING t0" + " WHERE t0.ARTIST_ID #bindEqual($id) ORDER BY PAINTING_ID";
+		SQLTemplate query = new SQLTemplate(Painting.class, template);
+		query.setColumnNamesCapitalization(CapsStrategy.UPPER);
+		query.setParameters(Collections.singletonMap("id", null));
+
+		List<Painting> objects = context.performQuery(query);
+		assertEquals(1, objects.size());
+
+		Painting p = objects.get(0);
+		assertEquals(8, Cayenne.intPKForObject(p));
+	}
+
+	@Test
+	public void testFetchLimit() throws Exception {
+		createFourArtists();
+
+		int fetchLimit = 2;
+
+		// sanity check
+		assertTrue(fetchLimit < 4);
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(Artist.class, template);
+		query.setFetchLimit(fetchLimit);
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(fetchLimit, objects.size());
+		assertTrue(objects.get(0) instanceof Artist);
+	}
+
+	@Test
+	public void testFetchOffset() throws Exception {
+		createFourArtists();
+
+		int fetchOffset = 2;
+
+		// sanity check
+		assertTrue(fetchOffset < 4);
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(Artist.class, template);
+		query.setFetchOffset(fetchOffset);
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(4 - fetchOffset, objects.size());
+		assertTrue(objects.get(0) instanceof Artist);
+	}
+
+	@Test
+	public void testFetchOffsetFetchLimit() throws Exception {
+		createFourArtists();
+
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(Artist.class, template);
+		query.setFetchOffset(1);
+		query.setFetchLimit(2);
+
+		List<?> objects = context.performQuery(query);
+		assertEquals(2, objects.size());
+		assertTrue(objects.get(0) instanceof Artist);
+	}
+
+	@Test
+	public void testPageSize() throws Exception {
+		createFourArtists();
+
+		int pageSize = 3;
+
+		// sanity check
+		assertTrue(pageSize < 4);
+
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(Artist.class, template);
+
+		query.setPageSize(pageSize);
+
+		List<?> objects = context.performQuery(query);
+
+		assertEquals(4, objects.size());
+		assertTrue(objects.get(0) instanceof Artist);
+
+		assertTrue(objects instanceof IncrementalFaultList<?>);
+		IncrementalFaultList<?> pagedList = (IncrementalFaultList<?>) objects;
+		assertEquals(4 - pageSize, pagedList.getUnfetchedObjects());
+
+		// check if we can resolve subsequent pages
+		Artist artist = (Artist) objects.get(pageSize);
+
+		int expectUnresolved = 4 - pageSize - pageSize;
+		if (expectUnresolved < 0) {
+			expectUnresolved = 0;
+		}
+		assertEquals(expectUnresolved, pagedList.getUnfetchedObjects());
+		assertEquals("artist" + (pageSize + 2), artist.getArtistName());
+	}
+
+	@Test
+	public void testIteratedQuery() throws Exception {
+		createFourArtists();
+
+		String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
+		SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(Artist.class, template);
+
+		try (ResultIterator<?> it = context.performIteratedQuery(query);) {
+			long i = 0;
+
+			while (it.hasNextRow()) {
+				i++;
+
+				DataRow row = (DataRow) it.nextRow();
+				assertEquals(3, row.size());
+				assertEquals("artist" + (1 + i), row.get("ARTIST_NAME"));
+			}
+
+			assertEquals(4, i);
+		}
+
+	}
+
+	@Test
+	public void testQueryWithLineBreakAfterMacro() throws Exception {
+		createFourArtists();
+
+		// see CAY-726 for details
+		String template = "SELECT #result('count(*)' 'int' 'X')" + System.getProperty("line.separator") + "FROM ARTIST";
+		SQLTemplate query = sqlTemplateCustomizer.createSQLTemplate(Artist.class, template);
+		query.setFetchingDataRows(true);
+
+		List<?> result = context.performQuery(query);
+
+		assertEquals(4, ((DataRow) result.get(0)).get("X"));
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/access/MockOperationObserver.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/MockOperationObserver.java b/cayenne-server/src/test/java/org/apache/cayenne/access/MockOperationObserver.java
index 7970f0f..cc72063 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/MockOperationObserver.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/MockOperationObserver.java
@@ -70,11 +70,11 @@ public class MockOperationObserver implements OperationObserver {
         throw new CayenneRuntimeException(ex);
     }
 
-    public void nextRows(Query q, ResultIterator it) {
+    public void nextRows(Query q, ResultIterator<?> it) {
     }
 
     @Override
-    public void nextGeneratedRows(Query query, ResultIterator keys, ObjectId idToUpdate) {
+    public void nextGeneratedRows(Query query, ResultIterator<?> keys, ObjectId idToUpdate) {
     }
 
     public boolean isIteratedResult() {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyBase.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyBase.java b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyBase.java
index 59b5b73..ca73183 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyBase.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyBase.java
@@ -18,15 +18,6 @@
  ****************************************************************/
 package org.apache.cayenne.access.dbsync;
 
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.unit.di.server.ServerCase;
-
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -36,6 +27,15 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.unit.di.server.ServerCase;
+
 public class SchemaUpdateStrategyBase extends ServerCase {
 
 	@Inject
@@ -96,30 +96,21 @@ public class SchemaUpdateStrategyBase extends ServerCase {
 		}
 
 		String tableLabel = node.getAdapter().tableTypeForTable();
-		Connection con = null;
-		try {
-			con = node.getDataSource().getConnection();
-			ResultSet rs = con.getMetaData().getTables(null, null, "%", new String[] { tableLabel });
-			while (rs.next()) {
-				String dbName = rs.getString("TABLE_NAME");
+		try (Connection con = node.getDataSource().getConnection();) {
+
+			try (ResultSet rs = con.getMetaData().getTables(null, null, "%", new String[] { tableLabel });) {
+				while (rs.next()) {
+					String dbName = rs.getString("TABLE_NAME");
 
-				String name = tables.get(dbName);
+					String name = tables.get(dbName);
 
-				if (name != null) {
-					presentInDB.put(name, true);
+					if (name != null) {
+						presentInDB.put(name, true);
+					}
 				}
 			}
-			rs.close();
 		} catch (SQLException e) {
 			throw new CayenneRuntimeException(e);
-		} finally {
-			try {
-				if (con != null) {
-					con.close();
-				}
-			} catch (SQLException e) {
-				throw new CayenneRuntimeException(e);
-			}
 		}
 
 		return presentInDB;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java
index 4547957..85dc21f 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java
@@ -43,45 +43,44 @@ import static org.mockito.Mockito.mock;
 
 public class JDBCResultIteratorTest {
 
-    @Test
-    public void testNextDataRow() throws Exception {
-        Connection c = new MockConnection();
-        Statement s = new MockStatement(c);
-        MockResultSet rs = new MockResultSet("rs");
-        rs.addColumn("a", new Object[] { "1", "2", "3" });
+	@Test
+	public void testNextDataRow() throws Exception {
+		Connection c = new MockConnection();
+		Statement s = new MockStatement(c);
+		MockResultSet rs = new MockResultSet("rs");
+		rs.addColumn("a", new Object[] { "1", "2", "3" });
 
-        RowDescriptor descriptor = new RowDescriptorBuilder().setResultSet(rs).getDescriptor(new ExtendedTypeMap());
-        RowReader<?> rowReader = new DefaultRowReaderFactory().rowReader(descriptor, new MockQueryMetadata(),
-                mock(DbAdapter.class), Collections.<ObjAttribute, ColumnDescriptor> emptyMap());
+		RowDescriptor descriptor = new RowDescriptorBuilder().setResultSet(rs).getDescriptor(new ExtendedTypeMap());
+		RowReader<?> rowReader = new DefaultRowReaderFactory().rowReader(descriptor, new MockQueryMetadata(),
+				mock(DbAdapter.class), Collections.<ObjAttribute, ColumnDescriptor> emptyMap());
 
-        JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);
+		JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);
 
-        DataRow row = (DataRow) it.nextRow();
+		DataRow row = (DataRow) it.nextRow();
 
-        assertNotNull(row);
-        assertEquals(1, row.size());
-        assertEquals("1", row.get("a"));
-    }
+		assertNotNull(row);
+		assertEquals(1, row.size());
+		assertEquals("1", row.get("a"));
+	}
 
-    @Test
-    public void testClose() throws Exception {
-        Connection c = new MockConnection();
-        MockStatement s = new MockStatement(c);
-        MockResultSet rs = new MockResultSet("rs");
-        rs.addColumn("a", new Object[] { "1", "2", "3" });
+	@Test
+	public void testClose() throws Exception {
+		Connection c = new MockConnection();
+		MockStatement s = new MockStatement(c);
+		MockResultSet rs = new MockResultSet("rs");
+		rs.addColumn("a", new Object[] { "1", "2", "3" });
 
-        RowReader<?> rowReader = mock(RowReader.class);
+		RowReader<?> rowReader = mock(RowReader.class);
 
-        JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);
+		try (JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);) {
 
-        assertFalse(rs.isClosed());
-        assertFalse(s.isClosed());
-        assertFalse(c.isClosed());
+			assertFalse(rs.isClosed());
+			assertFalse(s.isClosed());
+			assertFalse(c.isClosed());
+		}
 
-        it.close();
-
-        assertTrue(rs.isClosed());
-        assertTrue(s.isClosed());
-    }
+		assertTrue(rs.isClosed());
+		assertTrue(s.isClosed());
+	}
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java
index 7b24e4e..2522343 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/SQLTemplateActionIT.java
@@ -56,321 +56,289 @@ import static org.junit.Assert.assertTrue;
 @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
 public class SQLTemplateActionIT extends ServerCase {
 
-    @Inject
-    protected ServerCaseDataSourceFactory dataSourceFactory;
+	@Inject
+	protected ServerCaseDataSourceFactory dataSourceFactory;
 
-    @Inject
-    protected DataNode node;
+	@Inject
+	protected DataNode node;
 
-    @Inject
-    protected JdbcAdapter adapter;
-
-    @Inject
-    protected ObjectContext objectContext;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    @Inject
-    protected SQLTemplateCustomizer sqlTemplateCustomizer;
-
-    protected TableHelper tArtist;
-
-    @Before
-    public void setUp() throws Exception {
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME", "DATE_OF_BIRTH");
-    }
-
-    protected void createFourArtists() throws Exception {
-
-        Date date = new Date(System.currentTimeMillis());
-
-        tArtist.insert(11, "artist2", date);
-        tArtist.insert(101, "artist3", date);
-        tArtist.insert(201, "artist4", date);
-        tArtist.insert(3001, "artist5", date);
-    }
-
-    @Test
-    public void testProperties() throws Exception {
-        SQLTemplate template = new SQLTemplate(Object.class, "AAAAA");      
-  
-        SQLTemplateAction action = new SQLTemplateAction(template, node);
-        assertSame(template, action.getQuery());
-        assertSame(node, action.dataNode);
-    }
-
-    @Test
-    public void testExecuteSelect() throws Exception {
-        createFourArtists();
-
-        String templateString = "SELECT * FROM ARTIST WHERE ARTIST_ID = #bind($id)";
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-        sqlTemplateCustomizer.updateSQLTemplate(template);
-
-        Map<String, Object> bindings = new HashMap<String, Object>();
-        bindings.put("id", 201l);
-        template.setParameters(bindings);
-
-        // must ensure the right SQLTemplateAction is created
-
-        SQLAction plan = adapter.getAction(template, node);
-        assertTrue(plan instanceof SQLTemplateAction);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-
-        try {
-            plan.performAction(c, observer);
-        }
-        finally {
-            c.close();
-        }
-
-        List<DataRow> rows = observer.rowsForQuery(template);
-        assertNotNull(rows);
-        assertEquals(1, rows.size());
-        DataRow row = rows.get(0);
-
-        // In the absence of ObjEntity most DB's return a Long here, except for Oracle
-        // that has no BIGINT type and
-        // returns BigDecimal, so do a Number comparison
-        Number id = (Number) row.get("ARTIST_ID");
-        assertNotNull(id);
-        assertEquals(((Number) bindings.get("id")).longValue(), id.longValue());
-        assertEquals("artist4", row.get("ARTIST_NAME"));
-        assertTrue(row.containsKey("DATE_OF_BIRTH"));
-    }
-
-    @Test
-    public void testSelectUtilDate() throws Exception {
-        createFourArtists();
-
-        String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.util.Date' 'DOB') "
-                + "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-        sqlTemplateCustomizer.updateSQLTemplate(template);
-
-        Map<String, Object> bindings = new HashMap<String, Object>();
-        bindings.put("id", 101);
-        template.setParameters(bindings);
-
-        SQLAction plan = adapter.getAction(template, node);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-
-        try {
-            plan.performAction(c, observer);
-        }
-        finally {
-            c.close();
-        }
-
-        List<DataRow> rows = observer.rowsForQuery(template);
-        assertNotNull(rows);
-        assertEquals(1, rows.size());
-        DataRow row = rows.get(0);
-
-        assertNotNull(row.get("DOB"));
-        assertEquals(java.util.Date.class, row.get("DOB").getClass());
-    }
-
-    @Test
-    public void testSelectSQLDate() throws Exception {
-        createFourArtists();
-
-        String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.sql.Date' 'DOB') "
-                + "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-        sqlTemplateCustomizer.updateSQLTemplate(template);
-
-        Map<String, Object> bindings = new HashMap<String, Object>();
-        bindings.put("id", 101);
-        template.setParameters(bindings);
-
-        SQLAction plan = adapter.getAction(template, node);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-
-        try {
-            plan.performAction(c, observer);
-        }
-        finally {
-            c.close();
-        }
-
-        List<DataRow> rows = observer.rowsForQuery(template);
-        assertNotNull(rows);
-        assertEquals(1, rows.size());
-        DataRow row = rows.get(0);
-
-        assertNotNull(row.get("DOB"));
-        assertEquals(java.sql.Date.class, row.get("DOB").getClass());
-    }
-
-    @Test
-    public void testSelectSQLTimestamp() throws Exception {
-        createFourArtists();
-
-        String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.sql.Timestamp' 'DOB') "
-                + "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-        sqlTemplateCustomizer.updateSQLTemplate(template);
-
-        Map<String, Object> bindings = new HashMap<String, Object>();
-        bindings.put("id", 201);
-        template.setParameters(bindings);
-
-        SQLAction plan = adapter.getAction(template, node);
-
-        MockOperationObserver observer = new MockOperationObserver();
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-
-        try {
-            plan.performAction(c, observer);
-        }
-        finally {
-            c.close();
-        }
-
-        List<DataRow> rows = observer.rowsForQuery(template);
-        assertNotNull(rows);
-        assertEquals(1, rows.size());
-        DataRow row = rows.get(0);
-
-        assertNotNull(row.get("DOB"));
-        // Sybase returns a Timestamp subclass... so can't test equality
-        assertTrue(java.sql.Timestamp.class.isAssignableFrom(row.get("DOB").getClass()));
-    }
-
-    @Test
-    public void testExecuteUpdate() throws Exception {
-        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
-                + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-
-        Map<String, Object> bindings = new HashMap<String, Object>();
-        bindings.put("id", new Long(1));
-        bindings.put("name", "a1");
-        bindings.put("dob", new Date(System.currentTimeMillis()));
-        template.setParameters(bindings);
-
-        SQLAction action = adapter.getAction(template, node);
-
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-        try {
-            MockOperationObserver observer = new MockOperationObserver();
-            action.performAction(c, observer);
-
-            int[] batches = observer.countsForQuery(template);
-            assertNotNull(batches);
-            assertEquals(1, batches.length);
-            assertEquals(1, batches[0]);
-        }
-        finally {
-            c.close();
-        }
-
-        assertEquals(1, tArtist.getRowCount());
-        assertEquals(1l, tArtist.getLong("ARTIST_ID"));
-        assertEquals("a1", tArtist.getString("ARTIST_NAME").trim());
-    }
-
-    @Test
-    public void testExecuteUpdateNoParameters() throws Exception {
-        createFourArtists();
-
-        SQLTemplate template = new SQLTemplate(
-                Object.class,
-                "delete from ARTIST where ARTIST_NAME like 'a%'");
-
-        SQLAction action = adapter.getAction(template, node);
-
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-        try {
-            MockOperationObserver observer = new MockOperationObserver();
-            action.performAction(c, observer);
-
-            int[] batches = observer.countsForQuery(template);
-            assertNotNull(batches);
-            assertEquals(1, batches.length);
-            assertEquals(4, batches[0]);
-        }
-        finally {
-            c.close();
-        }
-    }
-
-    @Test
-    public void testExecuteUpdateBatch() throws Exception {
-        String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
-                + "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
-        SQLTemplate template = new SQLTemplate(Object.class, templateString);
-
-        Map<String, Object> bindings1 = new HashMap<String, Object>();
-        bindings1.put("id", new Long(1));
-        bindings1.put("name", "a1");
-        bindings1.put("dob", new Date(System.currentTimeMillis()));
-
-        Map<String, Object> bindings2 = new HashMap<String, Object>();
-        bindings2.put("id", new Long(33));
-        bindings2.put("name", "a$$$$$");
-        bindings2.put("dob", new Date(System.currentTimeMillis()));
-        template.setParameters(new Map[] {
-                bindings1, bindings2
-        });
-
-        SQLAction genericAction = adapter.getAction(template, node);
-        assertTrue(genericAction instanceof SQLTemplateAction);
-        SQLTemplateAction action = (SQLTemplateAction) genericAction;
-
-        assertSame(node, action.dataNode);
-        assertSame(template, action.getQuery());
-
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
-        try {
-            MockOperationObserver observer = new MockOperationObserver();
-            action.performAction(c, observer);
-
-            int[] batches = observer.countsForQuery(template);
-            assertNotNull(batches);
-            assertEquals(2, batches.length);
-            assertEquals(1, batches[0]);
-            assertEquals(1, batches[1]);
-        }
-        finally {
-            c.close();
-        }
-
-        MockOperationObserver observer = new MockOperationObserver();
-        SelectQuery query = new SelectQuery(Artist.class);
-        query.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
-        node.performQueries(Collections.singletonList((Query) query), observer);
-
-        List<DataRow> data = observer.rowsForQuery(query);
-        assertEquals(2, data.size());
-        DataRow row1 = data.get(0);
-        assertEquals(bindings1.get("id"), row1.get("ARTIST_ID"));
-        assertEquals(bindings1.get("name"), row1.get("ARTIST_NAME"));
-        // to compare dates we need to create the binding correctly
-        // assertEquals(bindings1.get("dob"), row.get("DATE_OF_BIRTH"));
-
-        DataRow row2 = data.get(1);
-        assertEquals(bindings2.get("id"), row2.get("ARTIST_ID"));
-        assertEquals(bindings2.get("name"), row2.get("ARTIST_NAME"));
-        // to compare dates we need to create the binding correctly
-        // assertEquals(bindings2.get("dob"), row2.get("DATE_OF_BIRTH"));
-    }
-
-    @Test
-    public void testExtractTemplateString() throws Exception {
-        SQLTemplate template = new SQLTemplate(Artist.class, "A\nBC");
-        SQLTemplateAction action = new SQLTemplateAction(template, node);
-
-        assertEquals("A BC", action.extractTemplateString());
-    }
+	@Inject
+	protected JdbcAdapter adapter;
+
+	@Inject
+	protected ObjectContext objectContext;
+
+	@Inject
+	protected DBHelper dbHelper;
+
+	@Inject
+	protected SQLTemplateCustomizer sqlTemplateCustomizer;
+
+	protected TableHelper tArtist;
+
+	@Before
+	public void setUp() throws Exception {
+		tArtist = new TableHelper(dbHelper, "ARTIST");
+		tArtist.setColumns("ARTIST_ID", "ARTIST_NAME", "DATE_OF_BIRTH");
+	}
+
+	protected void createFourArtists() throws Exception {
+
+		Date date = new Date(System.currentTimeMillis());
+
+		tArtist.insert(11, "artist2", date);
+		tArtist.insert(101, "artist3", date);
+		tArtist.insert(201, "artist4", date);
+		tArtist.insert(3001, "artist5", date);
+	}
+
+	@Test
+	public void testProperties() throws Exception {
+		SQLTemplate template = new SQLTemplate(Object.class, "AAAAA");
+
+		SQLTemplateAction action = new SQLTemplateAction(template, node);
+		assertSame(template, action.getQuery());
+		assertSame(node, action.dataNode);
+	}
+
+	@Test
+	public void testExecuteSelect() throws Exception {
+		createFourArtists();
+
+		String templateString = "SELECT * FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+		SQLTemplate template = new SQLTemplate(Object.class, templateString);
+		sqlTemplateCustomizer.updateSQLTemplate(template);
+
+		Map<String, Object> bindings = new HashMap<String, Object>();
+		bindings.put("id", 201l);
+		template.setParameters(bindings);
+
+		// must ensure the right SQLTemplateAction is created
+
+		SQLAction plan = adapter.getAction(template, node);
+		assertTrue(plan instanceof SQLTemplateAction);
+
+		MockOperationObserver observer = new MockOperationObserver();
+
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			plan.performAction(c, observer);
+		}
+
+		List<DataRow> rows = observer.rowsForQuery(template);
+		assertNotNull(rows);
+		assertEquals(1, rows.size());
+		DataRow row = rows.get(0);
+
+		// In the absence of ObjEntity most DB's return a Long here, except for
+		// Oracle
+		// that has no BIGINT type and
+		// returns BigDecimal, so do a Number comparison
+		Number id = (Number) row.get("ARTIST_ID");
+		assertNotNull(id);
+		assertEquals(((Number) bindings.get("id")).longValue(), id.longValue());
+		assertEquals("artist4", row.get("ARTIST_NAME"));
+		assertTrue(row.containsKey("DATE_OF_BIRTH"));
+	}
+
+	@Test
+	public void testSelectUtilDate() throws Exception {
+		createFourArtists();
+
+		String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.util.Date' 'DOB') "
+				+ "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+		SQLTemplate template = new SQLTemplate(Object.class, templateString);
+		sqlTemplateCustomizer.updateSQLTemplate(template);
+
+		Map<String, Object> bindings = new HashMap<String, Object>();
+		bindings.put("id", 101);
+		template.setParameters(bindings);
+
+		SQLAction plan = adapter.getAction(template, node);
+
+		MockOperationObserver observer = new MockOperationObserver();
+
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			plan.performAction(c, observer);
+		}
+
+		List<DataRow> rows = observer.rowsForQuery(template);
+		assertNotNull(rows);
+		assertEquals(1, rows.size());
+		DataRow row = rows.get(0);
+
+		assertNotNull(row.get("DOB"));
+		assertEquals(java.util.Date.class, row.get("DOB").getClass());
+	}
+
+	@Test
+	public void testSelectSQLDate() throws Exception {
+		createFourArtists();
+
+		String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.sql.Date' 'DOB') "
+				+ "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+		SQLTemplate template = new SQLTemplate(Object.class, templateString);
+		sqlTemplateCustomizer.updateSQLTemplate(template);
+
+		Map<String, Object> bindings = new HashMap<String, Object>();
+		bindings.put("id", 101);
+		template.setParameters(bindings);
+
+		SQLAction plan = adapter.getAction(template, node);
+
+		MockOperationObserver observer = new MockOperationObserver();
+
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			plan.performAction(c, observer);
+		}
+
+		List<DataRow> rows = observer.rowsForQuery(template);
+		assertNotNull(rows);
+		assertEquals(1, rows.size());
+		DataRow row = rows.get(0);
+
+		assertNotNull(row.get("DOB"));
+		assertEquals(java.sql.Date.class, row.get("DOB").getClass());
+	}
+
+	@Test
+	public void testSelectSQLTimestamp() throws Exception {
+		createFourArtists();
+
+		String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.sql.Timestamp' 'DOB') "
+				+ "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
+		SQLTemplate template = new SQLTemplate(Object.class, templateString);
+		sqlTemplateCustomizer.updateSQLTemplate(template);
+
+		Map<String, Object> bindings = new HashMap<String, Object>();
+		bindings.put("id", 201);
+		template.setParameters(bindings);
+
+		SQLAction plan = adapter.getAction(template, node);
+
+		MockOperationObserver observer = new MockOperationObserver();
+
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			plan.performAction(c, observer);
+		}
+
+		List<DataRow> rows = observer.rowsForQuery(template);
+		assertNotNull(rows);
+		assertEquals(1, rows.size());
+		DataRow row = rows.get(0);
+
+		assertNotNull(row.get("DOB"));
+		// Sybase returns a Timestamp subclass... so can't test equality
+		assertTrue(java.sql.Timestamp.class.isAssignableFrom(row.get("DOB").getClass()));
+	}
+
+	@Test
+	public void testExecuteUpdate() throws Exception {
+		String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+				+ "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
+		SQLTemplate template = new SQLTemplate(Object.class, templateString);
+
+		Map<String, Object> bindings = new HashMap<String, Object>();
+		bindings.put("id", new Long(1));
+		bindings.put("name", "a1");
+		bindings.put("dob", new Date(System.currentTimeMillis()));
+		template.setParameters(bindings);
+
+		SQLAction action = adapter.getAction(template, node);
+
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			MockOperationObserver observer = new MockOperationObserver();
+			action.performAction(c, observer);
+
+			int[] batches = observer.countsForQuery(template);
+			assertNotNull(batches);
+			assertEquals(1, batches.length);
+			assertEquals(1, batches[0]);
+		}
+		assertEquals(1, tArtist.getRowCount());
+		assertEquals(1l, tArtist.getLong("ARTIST_ID"));
+		assertEquals("a1", tArtist.getString("ARTIST_NAME").trim());
+	}
+
+	@Test
+	public void testExecuteUpdateNoParameters() throws Exception {
+		createFourArtists();
+
+		SQLTemplate template = new SQLTemplate(Object.class, "delete from ARTIST where ARTIST_NAME like 'a%'");
+
+		SQLAction action = adapter.getAction(template, node);
+
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			MockOperationObserver observer = new MockOperationObserver();
+			action.performAction(c, observer);
+
+			int[] batches = observer.countsForQuery(template);
+			assertNotNull(batches);
+			assertEquals(1, batches.length);
+			assertEquals(4, batches[0]);
+		}
+	}
+
+	@Test
+	public void testExecuteUpdateBatch() throws Exception {
+		String templateString = "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, DATE_OF_BIRTH) "
+				+ "VALUES (#bind($id), #bind($name), #bind($dob 'DATE'))";
+		SQLTemplate template = new SQLTemplate(Object.class, templateString);
+
+		Map<String, Object> bindings1 = new HashMap<String, Object>();
+		bindings1.put("id", new Long(1));
+		bindings1.put("name", "a1");
+		bindings1.put("dob", new Date(System.currentTimeMillis()));
+
+		Map<String, Object> bindings2 = new HashMap<String, Object>();
+		bindings2.put("id", new Long(33));
+		bindings2.put("name", "a$$$$$");
+		bindings2.put("dob", new Date(System.currentTimeMillis()));
+		template.setParameters(new Map[] { bindings1, bindings2 });
+
+		SQLAction genericAction = adapter.getAction(template, node);
+		assertTrue(genericAction instanceof SQLTemplateAction);
+		SQLTemplateAction action = (SQLTemplateAction) genericAction;
+
+		assertSame(node, action.dataNode);
+		assertSame(template, action.getQuery());
+
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			MockOperationObserver observer = new MockOperationObserver();
+			action.performAction(c, observer);
+
+			int[] batches = observer.countsForQuery(template);
+			assertNotNull(batches);
+			assertEquals(2, batches.length);
+			assertEquals(1, batches[0]);
+			assertEquals(1, batches[1]);
+		}
+
+		MockOperationObserver observer = new MockOperationObserver();
+		SelectQuery query = new SelectQuery(Artist.class);
+		query.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
+		node.performQueries(Collections.singletonList((Query) query), observer);
+
+		List<DataRow> data = observer.rowsForQuery(query);
+		assertEquals(2, data.size());
+		DataRow row1 = data.get(0);
+		assertEquals(bindings1.get("id"), row1.get("ARTIST_ID"));
+		assertEquals(bindings1.get("name"), row1.get("ARTIST_NAME"));
+		// to compare dates we need to create the binding correctly
+		// assertEquals(bindings1.get("dob"), row.get("DATE_OF_BIRTH"));
+
+		DataRow row2 = data.get(1);
+		assertEquals(bindings2.get("id"), row2.get("ARTIST_ID"));
+		assertEquals(bindings2.get("name"), row2.get("ARTIST_NAME"));
+		// to compare dates we need to create the binding correctly
+		// assertEquals(bindings2.get("dob"), row2.get("DATE_OF_BIRTH"));
+	}
+
+	@Test
+	public void testExtractTemplateString() throws Exception {
+		SQLTemplate template = new SQLTemplate(Artist.class, "A\nBC");
+		SQLTemplateAction action = new SQLTemplateAction(template, node);
+
+		assertEquals("A BC", action.extractTemplateString());
+	}
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferIT.java b/cayenne-server/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferIT.java
index 78b1c31..d5704a9 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/dba/sqlserver/SQLServerSnifferIT.java
@@ -19,6 +19,11 @@
 
 package org.apache.cayenne.dba.sqlserver;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.sql.Connection;
+
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.Inject;
@@ -30,49 +35,33 @@ import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.junit.Test;
 
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
 @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
 public class SQLServerSnifferIT extends ServerCase {
 
-    @Inject
-    private ServerCaseDataSourceFactory dataSourceFactory;
+	@Inject
+	private ServerCaseDataSourceFactory dataSourceFactory;
 
-    @Inject
-    private UnitDbAdapter accessStackAdapter;
-    
-    @Inject
-    private AdhocObjectFactory objectFactory;
+	@Inject
+	private UnitDbAdapter accessStackAdapter;
 
-    @Test
-    public void testCreateAdapter() throws Exception {
+	@Inject
+	private AdhocObjectFactory objectFactory;
 
-        SQLServerSniffer sniffer = new SQLServerSniffer(objectFactory);
+	@Test
+	public void testCreateAdapter() throws Exception {
 
-        DbAdapter adapter = null;
-        Connection c = dataSourceFactory.getSharedDataSource().getConnection();
+		SQLServerSniffer sniffer = new SQLServerSniffer(objectFactory);
 
-        try {
-            adapter = sniffer.createAdapter(c.getMetaData());
-        }
-        finally {
-            try {
-                c.close();
-            }
-            catch (SQLException e) {
+		DbAdapter adapter = null;
 
-            }
-        }
+		try (Connection c = dataSourceFactory.getSharedDataSource().getConnection();) {
+			adapter = sniffer.createAdapter(c.getMetaData());
+		}
 
-        if (accessStackAdapter instanceof SQLServerUnitDbAdapter) {
-            assertNotNull(adapter);
-        }
-        else {
-            assertNull(adapter);
-        }
-    }
+		if (accessStackAdapter instanceof SQLServerUnitDbAdapter) {
+			assertNotNull(adapter);
+		} else {
+			assertNull(adapter);
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java b/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java
index 266bb69..2764c3a 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/merge/MergeCase.java
@@ -103,14 +103,14 @@ public abstract class MergeCase extends ServerCase {
 		return new DbMerger(mergerFactory, valueForNullProvider);
 	}
 
-    protected List<MergerToken> createMergeTokens() {
-        DbLoaderConfiguration loaderConfiguration = new DbLoaderConfiguration();
-        loaderConfiguration.setFiltersConfig(FiltersConfig.create(null, null,
-                TableFilter.include("ARTIST|GALLERY|PAINTING|NEW_TABLE2?"), PatternFilter.INCLUDE_NOTHING));
+	protected List<MergerToken> createMergeTokens() {
+		DbLoaderConfiguration loaderConfiguration = new DbLoaderConfiguration();
+		loaderConfiguration.setFiltersConfig(FiltersConfig.create(null, null,
+				TableFilter.include("ARTIST|GALLERY|PAINTING|NEW_TABLE2?"), PatternFilter.INCLUDE_NOTHING));
 
-        return createMerger(node.getAdapter().mergerFactory())
-                .createMergeTokens(node.getDataSource(), node.getAdapter(), map, loaderConfiguration);
-    }
+		return createMerger(node.getAdapter().mergerFactory()).createMergeTokens(node.getDataSource(),
+				node.getAdapter(), map, loaderConfiguration);
+	}
 
 	/**
 	 * Remote binary pk {@link DbEntity} for {@link DbAdapter} not supporting
@@ -158,21 +158,13 @@ public abstract class MergeCase extends ServerCase {
 	}
 
 	private void executeSql(String sql) throws Exception {
-		Connection conn = dataSourceFactory.getSharedDataSource().getConnection();
 
-		try {
-			Statement st = conn.createStatement();
+		try (Connection conn = dataSourceFactory.getSharedDataSource().getConnection();) {
 
-			try {
+			try (Statement st = conn.createStatement();) {
 				st.execute(sql);
-			} finally {
-				st.close();
 			}
 		}
-
-		finally {
-			conn.close();
-		}
 	}
 
 	protected void assertTokens(List<MergerToken> tokens, int expectedToDb, int expectedToModel) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
index 40df636..c10056f 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
@@ -18,6 +18,14 @@
  ****************************************************************/
 package org.apache.cayenne.query;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ResultBatchIterator;
@@ -33,14 +41,6 @@ import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.junit.Test;
 
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
 @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
 public class ObjectSelect_RunIT extends ServerCase {
 
@@ -75,61 +75,53 @@ public class ObjectSelect_RunIT extends ServerCase {
 		assertEquals("artist14", a.getArtistName());
 	}
 
-    @Test
-    public void test_Iterate() throws Exception {
-        createArtistsDataSet();
-
-        final int[] count = new int[1];
-        ObjectSelect.query(Artist.class).iterate(context, new ResultIteratorCallback<Artist>() {
-
-            @Override
-            public void next(Artist object) {
-                assertNotNull(object.getArtistName());
-                count[0]++;
-            }
-        });
+	@Test
+	public void test_Iterate() throws Exception {
+		createArtistsDataSet();
 
-        assertEquals(20, count[0]);
-    }
+		final int[] count = new int[1];
+		ObjectSelect.query(Artist.class).iterate(context, new ResultIteratorCallback<Artist>() {
 
-    @Test
-    public void test_Iterator() throws Exception {
-        createArtistsDataSet();
+			@Override
+			public void next(Artist object) {
+				assertNotNull(object.getArtistName());
+				count[0]++;
+			}
+		});
 
-        ResultIterator<Artist> it = ObjectSelect.query(Artist.class).iterator(context);
+		assertEquals(20, count[0]);
+	}
 
-        try {
-            int count = 0;
+	@Test
+	public void test_Iterator() throws Exception {
+		createArtistsDataSet();
 
-            for (Artist a : it) {
-                count++;
-            }
+		try (ResultIterator<Artist> it = ObjectSelect.query(Artist.class).iterator(context)) {
+			int count = 0;
 
-            assertEquals(20, count);
-        } finally {
-            it.close();
-        }
-    }
+			for (Artist a : it) {
+				count++;
+			}
 
-    @Test
-    public void test_BatchIterator() throws Exception {
-        createArtistsDataSet();
+			assertEquals(20, count);
+		}
+	}
 
-        ResultBatchIterator<Artist> it = ObjectSelect.query(Artist.class).batchIterator(context, 5);
+	@Test
+	public void test_BatchIterator() throws Exception {
+		createArtistsDataSet();
 
-        try {
-            int count = 0;
+		try (ResultBatchIterator<Artist> it = ObjectSelect.query(Artist.class).batchIterator(context, 5);) {
+			int count = 0;
 
-            for (List<Artist> artistList : it) {
-                count++;
-                assertEquals(5, artistList.size());
-            }
+			for (List<Artist> artistList : it) {
+				count++;
+				assertEquals(5, artistList.size());
+			}
 
-            assertEquals(4, count);
-        } finally {
-            it.close();
-        }
-    }
+			assertEquals(4, count);
+		}
+	}
 
 	@Test
 	public void test_SelectDataRows() throws Exception {
@@ -165,7 +157,7 @@ public class ObjectSelect_RunIT extends ServerCase {
 		createArtistsDataSet();
 		ObjectSelect.query(Artist.class).where(Artist.ARTIST_NAME.like("artist%")).selectOne(context);
 	}
-	
+
 	@Test
 	public void test_SelectFirst() throws Exception {
 		createArtistsDataSet();
@@ -175,15 +167,15 @@ public class ObjectSelect_RunIT extends ServerCase {
 		assertEquals("artist13", a.getArtistName());
 	}
 
-    @Test
-    public void test_SelectFirstByContext() throws Exception {
-        createArtistsDataSet();
+	@Test
+	public void test_SelectFirstByContext() throws Exception {
+		createArtistsDataSet();
 
-        ObjectSelect<Artist> q = ObjectSelect.query(Artist.class).where(Artist.ARTIST_NAME.eq("artist13"));
-        Artist a = context.selectFirst(q);
-        assertNotNull(a);
-        assertEquals("artist13", a.getArtistName());
-    }
+		ObjectSelect<Artist> q = ObjectSelect.query(Artist.class).where(Artist.ARTIST_NAME.eq("artist13"));
+		Artist a = context.selectFirst(q);
+		assertNotNull(a);
+		assertEquals("artist13", a.getArtistName());
+	}
 
 	@Test
 	public void test_SelectFirst_NoMatch() throws Exception {
@@ -194,8 +186,9 @@ public class ObjectSelect_RunIT extends ServerCase {
 	@Test
 	public void test_SelectFirst_MoreThanOneMatch() throws Exception {
 		createArtistsDataSet();
-		
-		Artist a = ObjectSelect.query(Artist.class).where(Artist.ARTIST_NAME.like("artist%")).orderBy("db:ARTIST_ID").selectFirst(context);
+
+		Artist a = ObjectSelect.query(Artist.class).where(Artist.ARTIST_NAME.like("artist%")).orderBy("db:ARTIST_ID")
+				.selectFirst(context);
 		assertNotNull(a);
 		assertEquals("artist1", a.getArtistName());
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/26d8434d/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java
index ca51c41..6c4de62 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java
@@ -18,6 +18,16 @@
  ****************************************************************/
 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.assertTrue;
+
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ResultBatchIterator;
 import org.apache.cayenne.ResultIterator;
@@ -33,16 +43,6 @@ import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.sql.Types;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
 @UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
 public class SQLSelectIT extends ServerCase {
 
@@ -58,15 +58,15 @@ public class SQLSelectIT extends ServerCase {
 	public void before() {
 
 		tPainting = new TableHelper(dbHelper, "PAINTING")
-                .setColumns("PAINTING_ID", "PAINTING_TITLE", "ESTIMATED_PRICE")
-                .setColumnTypes(Types.INTEGER, Types.VARCHAR, Types.DECIMAL);
+				.setColumns("PAINTING_ID", "PAINTING_TITLE", "ESTIMATED_PRICE").setColumnTypes(Types.INTEGER,
+						Types.VARCHAR, Types.DECIMAL);
 	}
 
-    protected void createPaintingsDataSet() throws Exception {
-        for (int i = 1; i <= 20; i++) {
-            tPainting.insert(i, "painting" + i, 10000. * i);
-        }
-    }
+	protected void createPaintingsDataSet() throws Exception {
+		for (int i = 1; i <= 20; i++) {
+			tPainting.insert(i, "painting" + i, 10000. * i);
+		}
+	}
 
 	@Test
 	public void test_DataRows_DataMapNameRoot() throws Exception {
@@ -99,7 +99,8 @@ public class SQLSelectIT extends ServerCase {
 
 		createPaintingsDataSet();
 
-		SQLSelect<Painting> q1 = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING").columnNameCaps(CapsStrategy.UPPER);
+		SQLSelect<Painting> q1 = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING").columnNameCaps(
+				CapsStrategy.UPPER);
 		assertFalse(q1.isFetchingDataRows());
 		List<Painting> result = context.select(q1);
 		assertEquals(20, result.size());
@@ -111,11 +112,12 @@ public class SQLSelectIT extends ServerCase {
 
 		createPaintingsDataSet();
 
-		SQLSelect<Painting> q1 = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a)");
+		SQLSelect<Painting> q1 = SQLSelect.query(Painting.class,
+				"SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a)");
 		q1.params("a", "painting3").columnNameCaps(CapsStrategy.UPPER);
 
 		assertFalse(q1.isFetchingDataRows());
-        Painting a = context.selectOne(q1);
+		Painting a = context.selectOne(q1);
 		assertEquals("painting3", a.getPaintingTitle());
 	}
 
@@ -125,7 +127,8 @@ public class SQLSelectIT extends ServerCase {
 		createPaintingsDataSet();
 
 		SQLSelect<Painting> q1 = SQLSelect.query(Painting.class,
-				"SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a) OR PAINTING_TITLE = #bind($b)").columnNameCaps(CapsStrategy.UPPER);
+				"SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a) OR PAINTING_TITLE = #bind($b)")
+				.columnNameCaps(CapsStrategy.UPPER);
 		q1.params("a", "painting3").params("b", "painting4");
 
 		List<Painting> result = context.select(q1);
@@ -174,7 +177,8 @@ public class SQLSelectIT extends ServerCase {
 		createPaintingsDataSet();
 
 		SQLSelect<Painting> q1 = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING")
-				.append(" WHERE PAINTING_TITLE = #bind($a)").params("a", "painting3").columnNameCaps(CapsStrategy.UPPER);
+				.append(" WHERE PAINTING_TITLE = #bind($a)").params("a", "painting3")
+				.columnNameCaps(CapsStrategy.UPPER);
 
 		List<Painting> result = context.select(q1);
 		assertEquals(1, result.size());
@@ -185,7 +189,8 @@ public class SQLSelectIT extends ServerCase {
 
 		createPaintingsDataSet();
 
-		List<Painting> result = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
+		List<Painting> result = SQLSelect
+				.query(Painting.class, "SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
 				.params("a", "painting3").columnNameCaps(CapsStrategy.UPPER).select(context);
 
 		assertEquals(1, result.size());
@@ -196,97 +201,91 @@ public class SQLSelectIT extends ServerCase {
 
 		createPaintingsDataSet();
 
-        Painting a = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
+		Painting a = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
 				.params("a", "painting3").columnNameCaps(CapsStrategy.UPPER).selectOne(context);
 
 		assertEquals("painting3", a.getPaintingTitle());
 	}
 
-    @Test
-    public void test_SelectFirst() throws Exception {
-        createPaintingsDataSet();
-
-        Painting p = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING ORDER BY PAINTING_TITLE").selectFirst(context);
-
-        assertNotNull(p);
-        assertEquals("painting1", p.getPaintingTitle());
-    }
-
-    @Test
-    public void test_SelectFirstByContext() throws Exception {
-        createPaintingsDataSet();
+	@Test
+	public void test_SelectFirst() throws Exception {
+		createPaintingsDataSet();
 
-        SQLSelect<Painting> q = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING ORDER BY PAINTING_TITLE");
-        Painting p = context.selectFirst(q);
+		Painting p = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING ORDER BY PAINTING_TITLE").selectFirst(
+				context);
 
-        assertNotNull(p);
-        assertEquals("painting1", p.getPaintingTitle());
-    }
+		assertNotNull(p);
+		assertEquals("painting1", p.getPaintingTitle());
+	}
 
-    @Test
-    public void test_Iterate() throws Exception {
-        createPaintingsDataSet();
+	@Test
+	public void test_SelectFirstByContext() throws Exception {
+		createPaintingsDataSet();
 
-        final int[] count = new int[1];
-        SQLSelect.query(Painting.class, "SELECT * FROM PAINTING").columnNameCaps(CapsStrategy.UPPER)
-                .iterate(context, new ResultIteratorCallback<Painting>() {
-                    @Override
-                    public void next(Painting object) {
-                        assertNotNull(object.getPaintingTitle());
-                        count[0]++;
-                    }
-                });
+		SQLSelect<Painting> q = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING ORDER BY PAINTING_TITLE");
+		Painting p = context.selectFirst(q);
 
-        assertEquals(20, count[0]);
-    }
+		assertNotNull(p);
+		assertEquals("painting1", p.getPaintingTitle());
+	}
 
-    @Test
-    public void test_Iterator() throws Exception {
-        createPaintingsDataSet();
+	@Test
+	public void test_Iterate() throws Exception {
+		createPaintingsDataSet();
 
-        ResultIterator<Painting> it = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING")
-                .columnNameCaps(CapsStrategy.UPPER).iterator(context);
+		final int[] count = new int[1];
+		SQLSelect.query(Painting.class, "SELECT * FROM PAINTING").columnNameCaps(CapsStrategy.UPPER)
+				.iterate(context, new ResultIteratorCallback<Painting>() {
+					@Override
+					public void next(Painting object) {
+						assertNotNull(object.getPaintingTitle());
+						count[0]++;
+					}
+				});
+
+		assertEquals(20, count[0]);
+	}
 
-        try {
-            int count = 0;
+	@Test
+	public void test_Iterator() throws Exception {
+		createPaintingsDataSet();
 
-            for (Painting p : it) {
-                count++;
-            }
+		try (ResultIterator<Painting> it = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING")
+				.columnNameCaps(CapsStrategy.UPPER).iterator(context);) {
+			int count = 0;
 
-            assertEquals(20, count);
-        } finally {
-            it.close();
-        }
-    }
+			for (Painting p : it) {
+				count++;
+			}
 
-    @Test
-    public void test_BatchIterator() throws Exception {
-        createPaintingsDataSet();
+			assertEquals(20, count);
+		}
+	}
 
-        ResultBatchIterator<Painting> it = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING")
-                .columnNameCaps(CapsStrategy.UPPER).batchIterator(context, 5);
+	@Test
+	public void test_BatchIterator() throws Exception {
+		createPaintingsDataSet();
 
-        try {
-            int count = 0;
+		try (ResultBatchIterator<Painting> it = SQLSelect.query(Painting.class, "SELECT * FROM PAINTING")
+				.columnNameCaps(CapsStrategy.UPPER).batchIterator(context, 5);) {
+			int count = 0;
 
-            for (List<Painting> paintingList : it) {
-                count++;
-                assertEquals(5, paintingList.size());
-            }
+			for (List<Painting> paintingList : it) {
+				count++;
+				assertEquals(5, paintingList.size());
+			}
 
-            assertEquals(4, count);
-        } finally {
-            it.close();
-        }
-    }
+			assertEquals(4, count);
+		}
+	}
 
 	@Test
 	public void test_SelectLong() throws Exception {
 
 		createPaintingsDataSet();
 
-		long id = SQLSelect.scalarQuery(Integer.class, "SELECT PAINTING_ID FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
+		long id = SQLSelect
+				.scalarQuery(Integer.class, "SELECT PAINTING_ID FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
 				.params("a", "painting3").selectOne(context);
 
 		assertEquals(3l, id);
@@ -297,8 +296,8 @@ public class SQLSelectIT extends ServerCase {
 
 		createPaintingsDataSet();
 
-		List<Integer> ids = SQLSelect.scalarQuery(Integer.class, "SELECT PAINTING_ID FROM PAINTING ORDER BY PAINTING_ID").select(
-				context);
+		List<Integer> ids = SQLSelect.scalarQuery(Integer.class,
+				"SELECT PAINTING_ID FROM PAINTING ORDER BY PAINTING_ID").select(context);
 
 		assertEquals(20, ids.size());
 		assertEquals(2l, ids.get(1).intValue());
@@ -309,7 +308,8 @@ public class SQLSelectIT extends ServerCase {
 
 		createPaintingsDataSet();
 
-		int c = SQLSelect.scalarQuery(Integer.class, "SELECT #result('COUNT(*)' 'int') FROM PAINTING").selectOne(context);
+		int c = SQLSelect.scalarQuery(Integer.class, "SELECT #result('COUNT(*)' 'int') FROM PAINTING").selectOne(
+				context);
 
 		assertEquals(20, c);
 	}
@@ -319,7 +319,8 @@ public class SQLSelectIT extends ServerCase {
 
 		createPaintingsDataSet();
 
-        Integer id = SQLSelect.scalarQuery(Integer.class, "SELECT PAINTING_ID FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
+		Integer id = SQLSelect
+				.scalarQuery(Integer.class, "SELECT PAINTING_ID FROM PAINTING WHERE PAINTING_TITLE = #bind($a)")
 				.paramsArray("painting3").selectOne(context);
 
 		assertEquals(3l, id.intValue());
@@ -369,11 +370,11 @@ public class SQLSelectIT extends ServerCase {
 
 		List<Integer> ids = SQLSelect
 				.scalarQuery(
-                        Integer.class,
+						Integer.class,
 						"SELECT PAINTING_ID FROM PAINTING #chain('OR' 'WHERE') "
 								+ "#chunk($a) ESTIMATED_PRICE #bindEqual($a) #end "
-								+ "#chunk($b) PAINTING_TITLE #bindEqual($b) #end #end ORDER BY PAINTING_ID").params(params)
-				.select(context);
+								+ "#chunk($b) PAINTING_TITLE #bindEqual($b) #end #end ORDER BY PAINTING_ID")
+				.params(params).select(context);
 
 		assertEquals(1, ids.size());
 		assertEquals(1l, ids.get(0).longValue());


Mime
View raw message