Search in sources :

Example 1 with EmbeddedVariableCommentIllegalParameterBeanSpecificationException

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

the class NodeChecker method throwBindOrEmbeddedCommentIllegalParameterBeanSpecificationException.

public static void throwBindOrEmbeddedCommentIllegalParameterBeanSpecificationException(String expression, String specifiedSql, boolean bind) {
    final String name = (bind ? "bind variable" : "embedded variable");
    final String emmark = (bind ? "" : "$");
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The " + name + " comment had the illegal parameter-bean specification.");
    br.addItem("Advice");
    br.addElement("At first, is it really " + name + " comment?");
    br.addElement("Have you had a spell miss?");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    /*IE pmb...*/");
    br.addElement("    /*FUOR pmb...*/");
    br.addElement("    /*BIGAN*/");
    br.addElement("  (o):");
    br.addElement("    /*IF pmb...*/");
    br.addElement("    /*FOR pmb...*/");
    br.addElement("    /*BEGIN*/");
    br.addElement("");
    br.addElement("If you want to set " + name + "comment,");
    br.addElement("confirm the spell of parameter-bean expression.");
    br.addElement("(using parameter-bean, it should be named 'pmb')");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    /*" + emmark + "pmb,memberId*/");
    br.addElement("    /*" + emmark + "p mb.memberId*/");
    br.addElement("    /*" + emmark + "pmb:memberId*/");
    br.addElement("    /*" + emmark + "pnb.memberId*/");
    br.addElement("  (o):");
    br.addElement("    /*" + emmark + "pmb.memberId*/");
    br.addElement("");
    br.addElement("Or does it contain native binding mark '?' in your SQL?");
    br.addElement("You cannot use native binding, use bind variable comment instead.");
    br.addElement("  (x):");
    br.addElement("    where MEMBER_ID = ? -- *NG");
    br.addElement("  (o):");
    br.addElement("    where MEMBER_ID = /*pmb.memberId*/ -- OK");
    br.addItem("Comment Expression");
    br.addElement(expression);
    // *debug to this exception does not need contents of the parameter-bean
    // (and for security to application data)
    // br.addItem("ParameterBean");
    // br.addElement(pmb);
    br.addItem("Specified SQL");
    br.addElement(specifiedSql);
    final String msg = br.buildExceptionMessage();
    if (bind) {
        throw new BindVariableCommentIllegalParameterBeanSpecificationException(msg);
    } else {
        throw new EmbeddedVariableCommentIllegalParameterBeanSpecificationException(msg);
    }
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) BindVariableCommentIllegalParameterBeanSpecificationException(org.dbflute.twowaysql.exception.BindVariableCommentIllegalParameterBeanSpecificationException) EmbeddedVariableCommentIllegalParameterBeanSpecificationException(org.dbflute.twowaysql.exception.EmbeddedVariableCommentIllegalParameterBeanSpecificationException)

Aggregations

ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 BindVariableCommentIllegalParameterBeanSpecificationException (org.dbflute.twowaysql.exception.BindVariableCommentIllegalParameterBeanSpecificationException)1 EmbeddedVariableCommentIllegalParameterBeanSpecificationException (org.dbflute.twowaysql.exception.EmbeddedVariableCommentIllegalParameterBeanSpecificationException)1