List of usage examples for org.springframework.jdbc.core JdbcTemplate setResultsMapCaseInsensitive
public void setResultsMapCaseInsensitive(boolean resultsMapCaseInsensitive)
From source file:org.springframework.jdbc.core.JdbcTemplateTests.java
public void testCaseInsensitiveResultsMap() throws Exception { MockControl ctrlCallable;//w ww . j ava2s. c om CallableStatement mockCallable; ctrlCallable = MockControl.createControl(CallableStatement.class); mockCallable = (CallableStatement) ctrlCallable.getMock(); mockCallable.execute(); ctrlCallable.setReturnValue(false); mockCallable.getUpdateCount(); ctrlCallable.setReturnValue(-1); mockCallable.getObject(1); ctrlCallable.setReturnValue("X"); if (debugEnabled) { mockCallable.getWarnings(); ctrlCallable.setReturnValue(null); } mockCallable.close(); ctrlCallable.setVoidCallable(); mockConnection.prepareCall("my query"); ctrlConnection.setReturnValue(mockCallable); ctrlCallable.replay(); replay(); JdbcTemplate template = new JdbcTemplate(mockDataSource); assertTrue("default should have been NOT case insensitive", !template.isResultsMapCaseInsensitive()); template.setResultsMapCaseInsensitive(true); assertTrue("now it should have been set to case insensitive", template.isResultsMapCaseInsensitive()); List params = new ArrayList(); params.add(new SqlOutParameter("a", 12)); Map out = template.call(new CallableStatementCreator() { public CallableStatement createCallableStatement(Connection conn) throws SQLException { return conn.prepareCall("my query"); } }, params); assertTrue("this should have been a LinkedCaseInsensitiveMap", out instanceof LinkedCaseInsensitiveMap); assertNotNull("we should have gotten the result with upper case", out.get("A")); assertNotNull("we should have gotten the result with lower case", out.get("a")); ctrlCallable.verify(); }