コード例 #1
0
 protected String defaultLocate(String pathOrSql, StatementContext context) throws Exception {
   if (defaultLocator == null) {
     return pathOrSql;
   } else {
     return defaultLocator.locate(pathOrSql, context);
   }
 }
コード例 #2
0
  @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
  }