protected StatementLocator getStatementLocator() { return new ClasspathStatementLocator(); }
protected StatementLocator getStatementLocator() { return new ClasspathStatementLocator(); }
@Test public void testCachesOriginalQueryWhenNotFound() throws Exception { StatementLocator statementLocator = new ClasspathStatementLocator(); StatementContext statementContext = new TestingStatementContext(new HashMap<String, Object>()) { @Override public Class<?> getSqlObjectType() { return TestClasspathStatementLocator.class; } }; String input = "missing query"; String located = statementLocator.locate(input, statementContext); assertEquals(input, located); // first time just caches it located = statementLocator.locate(input, statementContext); assertEquals(input, located); // second time reads from cache } }
@Test public void testCachesOriginalQueryWhenNotFound() throws Exception { StatementLocator statementLocator = new ClasspathStatementLocator(); StatementContext statementContext = new TestingStatementContext(new HashMap<String, Object>()) { @Override public Class<?> getSqlObjectType() { return TestClasspathStatementLocator.class; } @Override public Method getSqlObjectMethod() { return null; } }; String input = "missing query"; String located = statementLocator.locate(input, statementContext); assertEquals(input, located); // first time just caches it located = statementLocator.locate(input, statementContext); assertEquals(input, located); // second time reads from cache }
@Test public void testCachesOriginalQueryByMethodWhenNotFound() throws Exception { StatementLocator statementLocator = new ClasspathStatementLocator(); StatementContext statementContext = new TestingStatementContext(new HashMap<String, Object>()) { @Override public Class<?> getSqlObjectType() { return TestClasspathStatementLocator.class; } @Override public Method getSqlObjectMethod() { try { return TestClasspathStatementLocator.class.getMethod("testCachesOriginalQueryByMethodWhenNotFound"); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } } }; String input = "missing query"; String located = statementLocator.locate(input, statementContext); assertEquals(input, located); // first time just caches it located = statementLocator.locate(input, statementContext); assertEquals(input, located); // second time reads from cache }
new ClasspathStatementLocator(), builder, new ColonPrefixNamedParamStatementRewriter(),
new ClasspathStatementLocator(), builder, new ColonPrefixNamedParamStatementRewriter(),