Search in sources :

Example 1 with InLoopOptionOutOfLoopException

use of org.dbflute.twowaysql.exception.InLoopOptionOutOfLoopException in project dbflute-core by dbflute.

the class NodeChecker method throwInLoopOptionOutOfLoopException.

public static void throwInLoopOptionOutOfLoopException(String expression, String specifiedSql, String option) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The in-loop option of variable comment was out of loop.");
    br.addItem("Advice");
    br.addElement("The in-loop options are supported in loop only.");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    /*pmb.memberName:notLike*/");
    br.addElement("    /*FOR ...*/");
    br.addElement("    /*END*/");
    br.addElement("  (o):");
    br.addElement("    /*FOR ...*/");
    br.addElement("    /*pmb.memberName:notLike*/");
    br.addElement("    /*END*/");
    br.addItem("Comment Expression");
    br.addElement(expression);
    br.addItem("In-Loop Option");
    br.addElement(option);
    br.addItem("Specified SQL");
    br.addElement(specifiedSql);
    final String msg = br.buildExceptionMessage();
    throw new InLoopOptionOutOfLoopException(msg);
}
Also used : InLoopOptionOutOfLoopException(org.dbflute.twowaysql.exception.InLoopOptionOutOfLoopException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder)

Example 2 with InLoopOptionOutOfLoopException

use of org.dbflute.twowaysql.exception.InLoopOptionOutOfLoopException in project dbflute-core by dbflute.

the class BindVariableNodeTest method test_accept_inLoopOption_outOfLoop.

public void test_accept_inLoopOption_outOfLoop() {
    // ## Arrange ##
    String sql = "= /*pmb.memberName:notLike*/'foo'";
    SqlAnalyzer analyzer = new SqlAnalyzer(sql, false);
    Node rootNode = analyzer.analyze();
    MockMemberPmb pmb = new MockMemberPmb();
    pmb.setMemberName("bar");
    CommandContext ctx = createCtx(pmb);
    // ## Act ##
    try {
        rootNode.accept(ctx);
        // ## Assert ##
        fail();
    } catch (InLoopOptionOutOfLoopException e) {
        // OK
        log(e.getMessage());
    }
}
Also used : InLoopOptionOutOfLoopException(org.dbflute.twowaysql.exception.InLoopOptionOutOfLoopException) CommandContext(org.dbflute.twowaysql.context.CommandContext) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Aggregations

InLoopOptionOutOfLoopException (org.dbflute.twowaysql.exception.InLoopOptionOutOfLoopException)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 SqlAnalyzer (org.dbflute.twowaysql.SqlAnalyzer)1 CommandContext (org.dbflute.twowaysql.context.CommandContext)1