Search in sources :

Example 1 with EmbeddedVariableCommentParameterNullValueException

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

the class EmbeddedVariableNodeTest method test_accept_null_notAllowed.

public void test_accept_null_notAllowed() {
    // ## Arrange ##
    String sql = "= /*$pmb.memberId*/8";
    SqlAnalyzer analyzer = new SqlAnalyzer(sql, true);
    Node rootNode = analyzer.analyze();
    MockMemberPmb pmb = new MockMemberPmb();
    CommandContext ctx = createCtx(pmb);
    // ## Act ##
    try {
        rootNode.accept(ctx);
        // ## Assert ##
        fail();
    } catch (EmbeddedVariableCommentParameterNullValueException e) {
        // OK
        log(e.getMessage());
    }
}
Also used : EmbeddedVariableCommentParameterNullValueException(org.dbflute.twowaysql.exception.EmbeddedVariableCommentParameterNullValueException) CommandContext(org.dbflute.twowaysql.context.CommandContext) SqlAnalyzer(org.dbflute.twowaysql.SqlAnalyzer)

Example 2 with EmbeddedVariableCommentParameterNullValueException

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

the class NodeChecker method throwBindOrEmbeddedCommentParameterNullValueException.

// ===================================================================================
// Exception Thrower
// =================
public static void throwBindOrEmbeddedCommentParameterNullValueException(String expression, Class<?> targetType, String specifiedSql, boolean bind) {
    final String name = (bind ? "bind variable" : "embedded variable");
    final String emmark = (bind ? "" : "$");
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The value of " + name + " was null.");
    br.addItem("Advice");
    br.addElement("Is it within the scope of your assumption?");
    br.addElement("If the answer is YES, please confirm your application logic about the parameter.");
    br.addElement("If the answer is NO, please confirm the logic of parameter comment(especially IF comment).");
    br.addElement("For example:");
    br.addElement("  (x) - XXX_ID = /*" + emmark + "pmb.xxxId*/3");
    br.addElement("  (o) - /*IF pmb.xxxId != null*/XXX_ID = /*" + emmark + "pmb.xxxId*/3/*END*/");
    br.addItem("Comment Expression");
    br.addElement(expression);
    br.addItem("Parameter Type");
    br.addElement(targetType);
    br.addItem("Specified SQL");
    br.addElement(specifiedSql);
    final String msg = br.buildExceptionMessage();
    if (bind) {
        throw new BindVariableCommentParameterNullValueException(msg);
    } else {
        throw new EmbeddedVariableCommentParameterNullValueException(msg);
    }
}
Also used : EmbeddedVariableCommentParameterNullValueException(org.dbflute.twowaysql.exception.EmbeddedVariableCommentParameterNullValueException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) BindVariableCommentParameterNullValueException(org.dbflute.twowaysql.exception.BindVariableCommentParameterNullValueException)

Aggregations

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