Java Code Examples for org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities#getAliasedEscapedColumnName()

The following examples show how to use org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities#getAliasedEscapedColumnName() . 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: HsqldbUpsertPlugin.java    From dolphin with Apache License 2.0 6 votes vote down vote up
protected void generateCopyForSetByPrefix(String fieldPrefix, String leftPrefix, String rightPrefix, boolean ifNullCheck, IntrospectedTable introspectedTable, XmlElement dynamicElement) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {

    sb.setLength(0);
    String columnName = MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn);
    sb.append(leftPrefix + columnName);
    sb.append(" = ");
    sb.append(rightPrefix + columnName);
    sb.append(',');

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  dynamicElement.addElement(trimElement);
}
 
Example 2
Source File: DB2UpsertPlugin.java    From dolphin with Apache License 2.0 6 votes vote down vote up
protected void generateCopyForSetByPrefix(String fieldPrefix, String leftPrefix, String rightPrefix, boolean ifNullCheck, IntrospectedTable introspectedTable, XmlElement dynamicElement) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {

    sb.setLength(0);
    String columnName = MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn);
    sb.append(leftPrefix + columnName);
    sb.append(" = ");
    sb.append(rightPrefix + columnName);
    sb.append(',');

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  dynamicElement.addElement(trimElement);
}
 
Example 3
Source File: HsqldbUpsertPlugin.java    From dolphin with Apache License 2.0 5 votes vote down vote up
@Override
protected XmlElement buildSqlClause(IntrospectedTable introspectedTable) {
  XmlElement sql = new XmlElement("sql");
  sql.addAttribute(new Attribute("id", IDENTIFIERS_ARRAY_CONDITIONS));

  XmlElement foreach = new XmlElement("foreach");
  foreach.addAttribute(new Attribute("collection", "array"));
  foreach.addAttribute(new Attribute("item", "item"));
  foreach.addAttribute(new Attribute("index", "index"));
  foreach.addAttribute(new Attribute("separator", " and "));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
    XmlElement isEqualElement = new XmlElement("if");
    sb.setLength(0);
    sb.append("item == \'");
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\'");
    isEqualElement.addAttribute(new Attribute("test", sb.toString()));
    foreach.addElement(isEqualElement);

    sb.setLength(0);

    String columnName = MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn);

    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime() + "." + columnName);
    sb.append(" = ");
    sb.append("temp." + columnName);

    isEqualElement.addElement(new TextElement(sb.toString()));
  }

  sql.addElement(foreach);

  return sql;
}
 
Example 4
Source File: DB2UpsertPlugin.java    From dolphin with Apache License 2.0 5 votes vote down vote up
@Override protected XmlElement buildSqlClause(IntrospectedTable introspectedTable) {
  XmlElement sql = new XmlElement("sql");
  sql.addAttribute(new Attribute("id", IDENTIFIERS_ARRAY_CONDITIONS));

  XmlElement foreach = new XmlElement("foreach");
  foreach.addAttribute(new Attribute("collection", "array"));
  foreach.addAttribute(new Attribute("item", "item"));
  foreach.addAttribute(new Attribute("index", "index"));
  foreach.addAttribute(new Attribute("separator", " and "));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
    XmlElement isEqualElement = new XmlElement("if");
    sb.setLength(0);
    sb.append("item == \'");
    sb.append(introspectedColumn.getJavaProperty());
    sb.append("\'");
    isEqualElement.addAttribute(new Attribute("test", sb.toString()));
    foreach.addElement(isEqualElement);

    sb.setLength(0);

    String columnName = MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn);

    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime() + "." + columnName);
    sb.append(" = ");
    sb.append("temp." + columnName);

    isEqualElement.addElement(new TextElement(sb.toString()));
  }

  sql.addElement(foreach);

  return sql;
}