Java Code Examples for org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities#getEscapedColumnName()
The following examples show how to use
org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities#getEscapedColumnName() .
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: OptimisticLockerPlugin.java From mybatis-generator-plugin with Apache License 2.0 | 6 votes |
/** * 生成版本号set节点 * @param selective * @return */ private TextElement generateVersionSetEle(boolean selective) { if (this.customizedNextVersion) { return new TextElement( (selective ? "" : "set ") + MyBatis3FormattingUtilities.getEscapedColumnName(this.versionColumn) + " = " + MyBatis3FormattingUtilities.getParameterClause(this.versionColumn, "record.") + "," ); } else { return new TextElement( (selective ? "" : "set ") + MyBatis3FormattingUtilities.getEscapedColumnName(this.versionColumn) + " = " + MyBatis3FormattingUtilities.getEscapedColumnName(this.versionColumn) + " + 1," ); } }
Example 2
Source File: IncrementPlugin.java From mybatis-generator-plugin with Apache License 2.0 | 5 votes |
@Override public XmlElement generateIncrementSet(IntrospectedColumn introspectedColumn, String prefix, boolean hasComma) { if (this.supportIncrement(introspectedColumn)) { // 条件 XmlElement choose = new XmlElement("choose"); // 启用增量操作 String columnMap = (prefix != null ? prefix : "_parameter.") + FIELD_INC_MAP + "." + MyBatis3FormattingUtilities.escapeStringForMyBatis3(introspectedColumn.getActualColumnName()); XmlElement whenIncEle = new XmlElement("when"); whenIncEle.addAttribute(new Attribute("test", columnMap + " != null")); TextElement spec = new TextElement( MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " = " + MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " ${" + columnMap + "." + FIELD_OPERATE_FOR_CLASS_INCREMENT + "} " + XmlElementGeneratorTools.getParameterClause(columnMap + "." + FIELD_VALUE_FOR_CLASS_INCREMENT, introspectedColumn) + (hasComma ? "," : "")); whenIncEle.addElement(spec); choose.addElement(whenIncEle); // 没有启用增量操作 XmlElement otherwiseEle = new XmlElement("otherwise"); otherwiseEle.addElement(new TextElement( MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " = " + MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, prefix) + (hasComma ? "," : "") )); choose.addElement(otherwiseEle); return choose; } return null; }
Example 3
Source File: IncrementPlugin.java From mybatis-generator-plugin with Apache License 2.0 | 5 votes |
@Override public XmlElement generateIncrementSetSelective(IntrospectedColumn introspectedColumn, String prefix) { if (this.supportIncrement(introspectedColumn)) { // 条件 XmlElement choose = new XmlElement("choose"); // 启用增量操作 String columnMap = (prefix != null ? prefix : "_parameter.") + FIELD_INC_MAP + "." + MyBatis3FormattingUtilities.escapeStringForMyBatis3(introspectedColumn.getActualColumnName()); XmlElement whenIncEle = new XmlElement("when"); whenIncEle.addAttribute(new Attribute("test", columnMap + " != null")); TextElement spec = new TextElement( MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " = " + MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " ${" + columnMap + "." + FIELD_OPERATE_FOR_CLASS_INCREMENT + "} " + XmlElementGeneratorTools.getParameterClause(columnMap + "." + FIELD_VALUE_FOR_CLASS_INCREMENT, introspectedColumn) + ","); whenIncEle.addElement(spec); choose.addElement(whenIncEle); // 没有启用增量操作 XmlElement whenEle = new XmlElement("when"); whenEle.addAttribute(new Attribute("test", introspectedColumn.getJavaProperty(prefix) + " != null")); whenEle.addElement(new TextElement(MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " = " + MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, prefix) + ",")); choose.addElement(whenEle); return choose; } return null; }
Example 4
Source File: IncrementsPlugin.java From mybatis-generator-plugin with Apache License 2.0 | 4 votes |
/** * 生成增量操作节点 * @param introspectedColumn * @param prefix * @param hasComma * @return */ @Override public List<Element> incrementSetElementGenerated(IntrospectedColumn introspectedColumn, String prefix, boolean hasComma) { List<Element> list = new ArrayList<>(); if (this.supportIncrement(introspectedColumn)) { // 1. column = 节点 list.add(new TextElement(MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " = ")); // 2. 选择节点 // 条件 XmlElement choose = new XmlElement("choose"); // 没有启用增量操作 XmlElement when = new XmlElement("when"); when.addAttribute(new Attribute( "test", (prefix != null ? prefix : "_parameter.") + IncrementsPlugin.METHOD_INC_CHECK + "('" + MyBatis3FormattingUtilities.escapeStringForMyBatis3(introspectedColumn.getActualColumnName()) + "')" )); TextElement spec = new TextElement( MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " ${" + (prefix != null ? prefix : "_parameter.") + IncrementsPlugin.METHOD_GET_INC_MAP + "()." + MyBatis3FormattingUtilities.escapeStringForMyBatis3(introspectedColumn.getActualColumnName()) + ".value} " + MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, prefix)); when.addElement(spec); choose.addElement(when); // 启用了增量操作 XmlElement otherwise = new XmlElement("otherwise"); TextElement normal = new TextElement(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, prefix)); otherwise.addElement(normal); choose.addElement(otherwise); list.add(choose); // 3. 结尾逗号 if (hasComma) { list.add(new TextElement(",")); } } return list; }