Java Code Examples for org.mybatis.generator.api.IntrospectedColumn#isJDBCTimeColumn()

The following examples show how to use org.mybatis.generator.api.IntrospectedColumn#isJDBCTimeColumn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExampleGenerator.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn, String nameFragment, String operator) {

        StringBuilder sb = new StringBuilder();
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
        sb.insert(0, "and");
        sb.append(nameFragment);

        Method method = new Method(sb.toString());
        method.setVisibility(JavaVisibility.PUBLIC);
        method.addParameter(new Parameter(introspectedColumn
                .getFullyQualifiedJavaType(), "value"));
        method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
        sb.setLength(0);

        if (introspectedColumn.isJDBCDateColumn()) {
            sb.append("addCriterionForJDBCDate(\"");
        } else if (introspectedColumn.isJDBCTimeColumn()) {
            sb.append("addCriterionForJDBCTime(\"");
        } else if (stringHasValue(introspectedColumn.getTypeHandler())) {
            sb.append("add");
            sb.append(introspectedColumn.getJavaProperty());
            sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
            sb.append("Criterion(\"");
        } else {
            sb.append("addCriterion(\"");
        }

        sb.append(MyBatis3FormattingUtilities.getAliasedActualColumnName(introspectedColumn));
        sb.append(' ');
        sb.append(operator);
        sb.append("\", ");
        sb.append("value");
        sb.append(", \"");
        sb.append(introspectedColumn.getJavaProperty());
        sb.append("\");");
        method.addBodyLine(sb.toString());
        method.addBodyLine("return (Criteria) this;");

        return method;
    }
 
Example 2
Source File: ExampleGenerator.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
/**
 * Generates methods that set between and not between conditions.
 *
 * @param introspectedColumn the introspected column
 * @param betweenMethod true if between, else not between
 * @return a generated method for the between or not between method
 */
private Method getSetBetweenOrNotBetweenMethod(
        IntrospectedColumn introspectedColumn, boolean betweenMethod) {

    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and");
    if (betweenMethod) {
        sb.append("Between");
    } else {
        sb.append("NotBetween");
    }
    Method method = new Method(sb.toString());
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = introspectedColumn.getFullyQualifiedJavaType();

    method.addParameter(new Parameter(type, "value1"));
    method.addParameter(new Parameter(type, "value2"));
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());

    sb.setLength(0);
    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\"");
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\"");
    } else if (stringHasValue(introspectedColumn.getTypeHandler())) {
        sb.append("add");
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\"");
    } else {
        sb.append("addCriterion(\"");
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (betweenMethod) {
        sb.append(" between");
    } else {
        sb.append(" not between");
    }
    sb.append("\", ");
    sb.append("value1, value2");
    sb.append(", \"");
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");");
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;");

    return method;
}
 
Example 3
Source File: ExampleGenerator.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
/**
 * Generates an In or NotIn method.
 *
 * @param introspectedColumn the introspected column
 * @param inMethod
 *            if true generates an "in" method, else generates a "not in"
 *            method
 * @return a generated method for the in or not in method
 */
private Method getSetInOrNotInMethod(IntrospectedColumn introspectedColumn,
                                     boolean inMethod) {
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and");
    if (inMethod) {
        sb.append("In");
    } else {
        sb.append("NotIn");
    }
    Method method = new Method(sb.toString());
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = FullyQualifiedJavaType.getNewListInstance();
    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
        type.addTypeArgument(introspectedColumn.getFullyQualifiedJavaType().getPrimitiveTypeWrapper());
    } else {
        type.addTypeArgument(introspectedColumn.getFullyQualifiedJavaType());
    }

    method.addParameter(new Parameter(type, "values"));
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());

    sb.setLength(0);
    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\"");
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\"");
    } else if (stringHasValue(introspectedColumn.getTypeHandler())) {
        sb.append("add");
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\"");
    } else {
        sb.append("addCriterion(\"");
    }

    sb.append(MyBatis3FormattingUtilities.getAliasedActualColumnName(introspectedColumn));
    if (inMethod) {
        sb.append(" in");
    } else {
        sb.append(" not in");
    }
    sb.append("\", values, \"");
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");");
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;");

    return method;
}
 
Example 4
Source File: ExampleGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn,
        String nameFragment, String operator) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.addParameter(new Parameter(introspectedColumn
            .getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    sb.append(nameFragment);
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(Ibatis2FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    sb.append(' ');
    sb.append(operator);
    sb.append("\", "); //$NON-NLS-1$

    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive() && !introspectedTable.isJava5Targeted()) {
        sb.append("new "); //$NON-NLS-1$
        sb.append(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper().getShortName());
        sb.append("(value)"); //$NON-NLS-1$
    } else {
        sb.append("value"); //$NON-NLS-1$
    }

    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 5
Source File: ExampleGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
/**
 * Generates methods that set between and not between conditions
 * 
 * @param introspectedColumn
 * @param betweenMethod
 * @return a generated method for the between or not between method
 */
private Method getSetBetweenOrNotBetweenMethod(
        IntrospectedColumn introspectedColumn, boolean betweenMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = introspectedColumn
            .getFullyQualifiedJavaType();

    method.addParameter(new Parameter(type, "value1")); //$NON-NLS-1$
    method.addParameter(new Parameter(type, "value2")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (betweenMethod) {
        sb.append("Between"); //$NON-NLS-1$
    } else {
        sb.append("NotBetween"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(Ibatis2FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (betweenMethod) {
        sb.append(" between"); //$NON-NLS-1$
    } else {
        sb.append(" not between"); //$NON-NLS-1$
    }
    sb.append("\", "); //$NON-NLS-1$
    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive() && !introspectedTable.isJava5Targeted()) {
        sb.append("new "); //$NON-NLS-1$
        sb.append(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper().getShortName());
        sb.append("(value1), "); //$NON-NLS-1$
        sb.append("new "); //$NON-NLS-1$
        sb.append(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper().getShortName());
        sb.append("(value2)"); //$NON-NLS-1$
    } else {
        sb.append("value1, value2"); //$NON-NLS-1$
    }

    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 6
Source File: ExampleGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param introspectedColumn
 * @param inMethod
 *            if true generates an "in" method, else generates a "not in"
 *            method
 * @return a generated method for the in or not in method
 */
private Method getSetInOrNotInMethod(IntrospectedColumn introspectedColumn,
        boolean inMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = FullyQualifiedJavaType
            .getNewListInstance();
    if (generateForJava5) {
        if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
            type.addTypeArgument(introspectedColumn
                    .getFullyQualifiedJavaType().getPrimitiveTypeWrapper());
        } else {
            type.addTypeArgument(introspectedColumn
                    .getFullyQualifiedJavaType());
        }
    }

    method.addParameter(new Parameter(type, "values")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (inMethod) {
        sb.append("In"); //$NON-NLS-1$
    } else {
        sb.append("NotIn"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(Ibatis2FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (inMethod) {
        sb.append(" in"); //$NON-NLS-1$
    } else {
        sb.append(" not in"); //$NON-NLS-1$
    }
    sb.append("\", values, \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 7
Source File: ExampleGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn,
        String nameFragment, String operator) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.addParameter(new Parameter(introspectedColumn
            .getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    sb.append(nameFragment);
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    sb.append(' ');
    sb.append(operator);
    sb.append("\", "); //$NON-NLS-1$
    sb.append("value"); //$NON-NLS-1$
    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 8
Source File: ExampleGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
/**
 * Generates methods that set between and not between conditions
 * 
 * @param introspectedColumn
 * @param betweenMethod
 * @return a generated method for the between or not between method
 */
private Method getSetBetweenOrNotBetweenMethod(
        IntrospectedColumn introspectedColumn, boolean betweenMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = introspectedColumn
            .getFullyQualifiedJavaType();

    method.addParameter(new Parameter(type, "value1")); //$NON-NLS-1$
    method.addParameter(new Parameter(type, "value2")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (betweenMethod) {
        sb.append("Between"); //$NON-NLS-1$
    } else {
        sb.append("NotBetween"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (betweenMethod) {
        sb.append(" between"); //$NON-NLS-1$
    } else {
        sb.append(" not between"); //$NON-NLS-1$
    }
    sb.append("\", "); //$NON-NLS-1$
    sb.append("value1, value2"); //$NON-NLS-1$
    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 9
Source File: ExampleGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param introspectedColumn
 * @param inMethod
 *            if true generates an "in" method, else generates a "not in"
 *            method
 * @return a generated method for the in or not in method
 */
private Method getSetInOrNotInMethod(IntrospectedColumn introspectedColumn,
        boolean inMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = FullyQualifiedJavaType
            .getNewListInstance();
    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
        type.addTypeArgument(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper());
    } else {
        type
                .addTypeArgument(introspectedColumn
                        .getFullyQualifiedJavaType());
    }

    method.addParameter(new Parameter(type, "values")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (inMethod) {
        sb.append("In"); //$NON-NLS-1$
    } else {
        sb.append("NotIn"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (inMethod) {
        sb.append(" in"); //$NON-NLS-1$
    } else {
        sb.append(" not in"); //$NON-NLS-1$
    }
    sb.append("\", values, \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 10
Source File: ExampleGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn,
        String nameFragment, String operator) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.addParameter(new Parameter(introspectedColumn
            .getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    sb.append(nameFragment);
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(Ibatis2FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    sb.append(' ');
    sb.append(operator);
    sb.append("\", "); //$NON-NLS-1$

    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive() && !introspectedTable.isJava5Targeted()) {
        sb.append("new "); //$NON-NLS-1$
        sb.append(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper().getShortName());
        sb.append("(value)"); //$NON-NLS-1$
    } else {
        sb.append("value"); //$NON-NLS-1$
    }

    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 11
Source File: ExampleGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
/**
 * Generates methods that set between and not between conditions
 * 
 * @param introspectedColumn
 * @param betweenMethod
 * @return a generated method for the between or not between method
 */
private Method getSetBetweenOrNotBetweenMethod(
        IntrospectedColumn introspectedColumn, boolean betweenMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = introspectedColumn
            .getFullyQualifiedJavaType();

    method.addParameter(new Parameter(type, "value1")); //$NON-NLS-1$
    method.addParameter(new Parameter(type, "value2")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (betweenMethod) {
        sb.append("Between"); //$NON-NLS-1$
    } else {
        sb.append("NotBetween"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(Ibatis2FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (betweenMethod) {
        sb.append(" between"); //$NON-NLS-1$
    } else {
        sb.append(" not between"); //$NON-NLS-1$
    }
    sb.append("\", "); //$NON-NLS-1$
    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive() && !introspectedTable.isJava5Targeted()) {
        sb.append("new "); //$NON-NLS-1$
        sb.append(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper().getShortName());
        sb.append("(value1), "); //$NON-NLS-1$
        sb.append("new "); //$NON-NLS-1$
        sb.append(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper().getShortName());
        sb.append("(value2)"); //$NON-NLS-1$
    } else {
        sb.append("value1, value2"); //$NON-NLS-1$
    }

    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 12
Source File: ExampleGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param introspectedColumn
 * @param inMethod
 *            if true generates an "in" method, else generates a "not in"
 *            method
 * @return a generated method for the in or not in method
 */
private Method getSetInOrNotInMethod(IntrospectedColumn introspectedColumn,
        boolean inMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = FullyQualifiedJavaType
            .getNewListInstance();
    if (generateForJava5) {
        if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
            type.addTypeArgument(introspectedColumn
                    .getFullyQualifiedJavaType().getPrimitiveTypeWrapper());
        } else {
            type.addTypeArgument(introspectedColumn
                    .getFullyQualifiedJavaType());
        }
    }

    method.addParameter(new Parameter(type, "values")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (inMethod) {
        sb.append("In"); //$NON-NLS-1$
    } else {
        sb.append("NotIn"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(Ibatis2FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (inMethod) {
        sb.append(" in"); //$NON-NLS-1$
    } else {
        sb.append(" not in"); //$NON-NLS-1$
    }
    sb.append("\", values, \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 13
Source File: ExampleGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn,
        String nameFragment, String operator) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.addParameter(new Parameter(introspectedColumn
            .getFullyQualifiedJavaType(), "value")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    sb.append(nameFragment);
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    sb.append(' ');
    sb.append(operator);
    sb.append("\", "); //$NON-NLS-1$
    sb.append("value"); //$NON-NLS-1$
    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 14
Source File: ExampleGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
/**
 * Generates methods that set between and not between conditions
 * 
 * @param introspectedColumn
 * @param betweenMethod
 * @return a generated method for the between or not between method
 */
private Method getSetBetweenOrNotBetweenMethod(
        IntrospectedColumn introspectedColumn, boolean betweenMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = introspectedColumn
            .getFullyQualifiedJavaType();

    method.addParameter(new Parameter(type, "value1")); //$NON-NLS-1$
    method.addParameter(new Parameter(type, "value2")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (betweenMethod) {
        sb.append("Between"); //$NON-NLS-1$
    } else {
        sb.append("NotBetween"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (betweenMethod) {
        sb.append(" between"); //$NON-NLS-1$
    } else {
        sb.append(" not between"); //$NON-NLS-1$
    }
    sb.append("\", "); //$NON-NLS-1$
    sb.append("value1, value2"); //$NON-NLS-1$
    sb.append(", \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
Example 15
Source File: ExampleGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @param introspectedColumn
 * @param inMethod
 *            if true generates an "in" method, else generates a "not in"
 *            method
 * @return a generated method for the in or not in method
 */
private Method getSetInOrNotInMethod(IntrospectedColumn introspectedColumn,
        boolean inMethod) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    FullyQualifiedJavaType type = FullyQualifiedJavaType
            .getNewListInstance();
    if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
        type.addTypeArgument(introspectedColumn.getFullyQualifiedJavaType()
                .getPrimitiveTypeWrapper());
    } else {
        type
                .addTypeArgument(introspectedColumn
                        .getFullyQualifiedJavaType());
    }

    method.addParameter(new Parameter(type, "values")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    if (inMethod) {
        sb.append("In"); //$NON-NLS-1$
    } else {
        sb.append("NotIn"); //$NON-NLS-1$
    }
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);

    if (introspectedColumn.isJDBCDateColumn()) {
        sb.append("addCriterionForJDBCDate(\""); //$NON-NLS-1$
    } else if (introspectedColumn.isJDBCTimeColumn()) {
        sb.append("addCriterionForJDBCTime(\""); //$NON-NLS-1$
    } else if (stringHasValue(introspectedColumn
            .getTypeHandler())) {
        sb.append("add"); //$NON-NLS-1$
        sb.append(introspectedColumn.getJavaProperty());
        sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
        sb.append("Criterion(\""); //$NON-NLS-1$
    } else {
        sb.append("addCriterion(\""); //$NON-NLS-1$
    }

    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    if (inMethod) {
        sb.append(" in"); //$NON-NLS-1$
    } else {
        sb.append(" not in"); //$NON-NLS-1$
    }
    sb.append("\", values, \""); //$NON-NLS-1$
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}