org.mybatis.generator.api.dom.xml.Attribute Java Examples
The following examples show how to use
org.mybatis.generator.api.dom.xml.Attribute.
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: JDBCConnectionConfiguration.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
public XmlElement toXmlElement() { XmlElement xmlElement = new XmlElement("jdbcConnection"); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute("driverClass", driverClass)); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute("connectionURL", connectionURL)); //$NON-NLS-1$ if (stringHasValue(userId)) { xmlElement.addAttribute(new Attribute("userId", userId)); //$NON-NLS-1$ } if (stringHasValue(password)) { xmlElement.addAttribute(new Attribute("password", password)); //$NON-NLS-1$ } addPropertyXmlElements(xmlElement); return xmlElement; }
Example #2
Source File: SimpleXMLMapperGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
protected XmlElement getSqlMapElement() { FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable(); progressCallback.startTask(getString("Progress.12", table.toString())); XmlElement answer = new XmlElement("mapper"); String namespace = introspectedTable.getMyBatis3SqlMapNamespace(); answer.addAttribute(new Attribute("namespace", namespace)); context.getCommentGenerator().addRootComment(answer); addResultMapElement(answer); addDeleteByPrimaryKeyElement(answer); addInsertElement(answer); addUpdateByPrimaryKeyElement(answer); addSelectByPrimaryKeyElement(answer); addSelectAllElement(answer); return answer; }
Example #3
Source File: OracleUpsertPlugin.java From dolphin with Apache License 2.0 | 6 votes |
@Override protected void generateSqlMapContentSelective(IntrospectedTable introspectedTable, XmlElement parent) { generateTextBlockAppendTableName("merge into ", introspectedTable, parent); generateTextBlock(" using dual on ( ", parent); XmlElement include = new XmlElement("include"); include.addAttribute(new Attribute("refid", IDENTIFIERS_ARRAY_CONDITIONS)); parent.addElement(include); generateTextBlock(" ) ", parent); generateTextBlock(" when matched then update set ", parent); generateParameterForSet(PROPERTY_PREFIX, true, introspectedTable.getAllColumns(), parent); generateTextBlock(" when not matched then insert ", parent); generateActualColumnNamesWithParenthesis(PROPERTY_PREFIX, true, introspectedTable.getAllColumns(), parent); generateTextBlock(" values ", parent); generateParametersSeparateByCommaWithParenthesis(PROPERTY_PREFIX, true, introspectedTable.getAllColumns(), parent); }
Example #4
Source File: PaginationPlugin.java From xxpay-master with MIT License | 6 votes |
/** * 为Mapper.xml的selectByExample添加limit,offset */ @Override public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) { XmlElement ifLimitNotNullElement = new XmlElement("if"); ifLimitNotNullElement.addAttribute(new Attribute("test", "limit != null")); XmlElement ifOffsetNotNullElement = new XmlElement("if"); ifOffsetNotNullElement.addAttribute(new Attribute("test", "offset != null")); ifOffsetNotNullElement.addElement(new TextElement("limit ${offset}, ${limit}")); ifLimitNotNullElement.addElement(ifOffsetNotNullElement); XmlElement ifOffsetNullElement = new XmlElement("if"); ifOffsetNullElement.addAttribute(new Attribute("test", "offset == null")); ifOffsetNullElement.addElement(new TextElement("limit ${limit}")); ifLimitNotNullElement.addElement(ifOffsetNullElement); element.addElement(ifLimitNotNullElement); return true; }
Example #5
Source File: AbstractXmlElementGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 6 votes |
/** * This method should return an XmlElement for the select key used to * automatically generate keys. * * @param introspectedColumn * the column related to the select key statement * @param generatedKey * the generated key for the current table * @return the selectKey element */ protected XmlElement getSelectKey(IntrospectedColumn introspectedColumn, GeneratedKey generatedKey) { String identityColumnType = introspectedColumn .getFullyQualifiedJavaType().getFullyQualifiedName(); XmlElement answer = new XmlElement("selectKey"); //$NON-NLS-1$ answer.addAttribute(new Attribute("resultType", identityColumnType)); //$NON-NLS-1$ answer.addAttribute(new Attribute( "keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$ answer.addAttribute(new Attribute("order", //$NON-NLS-1$ generatedKey.getMyBatis3Order())); answer.addElement(new TextElement(generatedKey .getRuntimeSqlStatement())); return answer; }
Example #6
Source File: ResultMapWithBLOBsElementGenerator.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
private void addResultMapElements(XmlElement answer) { for (IntrospectedColumn introspectedColumn : introspectedTable .getBLOBColumns()) { XmlElement resultElement = new XmlElement("result"); resultElement.addAttribute(generateColumnAttribute(introspectedColumn)); resultElement.addAttribute(new Attribute( "property", introspectedColumn.getJavaProperty())); resultElement.addAttribute(new Attribute( "jdbcType", introspectedColumn.getJdbcTypeName())); if (stringHasValue(introspectedColumn .getTypeHandler())) { resultElement.addAttribute(new Attribute( "typeHandler", introspectedColumn.getTypeHandler())); } answer.addElement(resultElement); } }
Example #7
Source File: AbstractXmbgPlugin.java From dolphin with Apache License 2.0 | 6 votes |
protected void generateWhereConditions(String fieldPrefix, String columnPrefix, boolean ifNullCheck, List<IntrospectedColumn> columns, XmlElement parent) { XmlElement trimElement = new XmlElement("trim"); trimElement.addAttribute(new Attribute("suffixOverrides", ",")); StringBuilder sb = new StringBuilder(); for (IntrospectedColumn introspectedColumn : columns) { sb.setLength(0); sb.append((columnPrefix == null ? "" : columnPrefix) + MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn)); sb.append(" = "); sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, fieldPrefix)); sb.append(","); doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn); } XmlElement where = new XmlElement("where"); where.addElement(trimElement); parent.addElement(where); }
Example #8
Source File: ResultMapWithBLOBsElementGenerator.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
private void addResultMapElements(XmlElement answer) { for (IntrospectedColumn introspectedColumn : introspectedTable .getBLOBColumns()) { XmlElement resultElement = new XmlElement("result"); //$NON-NLS-1$ resultElement .addAttribute(new Attribute( "column", MyBatis3FormattingUtilities.getRenamedColumnNameForResultMap(introspectedColumn))); //$NON-NLS-1$ resultElement.addAttribute(new Attribute( "property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$ resultElement.addAttribute(new Attribute( "jdbcType", introspectedColumn.getJdbcTypeName())); //$NON-NLS-1$ if (stringHasValue(introspectedColumn .getTypeHandler())) { resultElement.addAttribute(new Attribute( "typeHandler", introspectedColumn.getTypeHandler())); //$NON-NLS-1$ } answer.addElement(resultElement); } }
Example #9
Source File: CountByExampleElementGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 6 votes |
@Override public void addElements(XmlElement parentElement) { XmlElement answer = new XmlElement("select"); //$NON-NLS-1$ String fqjt = introspectedTable.getExampleType(); answer.addAttribute(new Attribute( "id", introspectedTable.getCountByExampleStatementId())); //$NON-NLS-1$ answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$ answer.addAttribute(new Attribute("resultType", "java.lang.Integer")); //$NON-NLS-1$ //$NON-NLS-2$ context.getCommentGenerator().addComment(answer); StringBuilder sb = new StringBuilder(); sb.append("select count(*) from "); //$NON-NLS-1$ sb.append(introspectedTable .getAliasedFullyQualifiedTableNameAtRuntime()); answer.addElement(new TextElement(sb.toString())); answer.addElement(getExampleIncludeElement()); if (context.getPlugins().sqlMapCountByExampleElementGenerated( answer, introspectedTable)) { parentElement.addElement(answer); } }
Example #10
Source File: DeleteByExampleElementGenerator.java From mybatis-generator-plus with Apache License 2.0 | 6 votes |
@Override public void addElements(XmlElement parentElement) { XmlElement answer = new XmlElement("delete"); //$NON-NLS-1$ String fqjt = introspectedTable.getExampleType(); answer.addAttribute(new Attribute( "id", introspectedTable.getDeleteByExampleStatementId())); //$NON-NLS-1$ answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$ context.getCommentGenerator().addComment(answer); StringBuilder sb = new StringBuilder(); sb.append("delete from "); //$NON-NLS-1$ sb.append(introspectedTable .getAliasedFullyQualifiedTableNameAtRuntime()); answer.addElement(new TextElement(sb.toString())); answer.addElement(getExampleIncludeElement()); if (context.getPlugins().sqlMapDeleteByExampleElementGenerated( answer, introspectedTable)) { parentElement.addElement(answer); } }
Example #11
Source File: CreateSubPackagePluginTest.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
@Test public void shouldRenameModelElementAttribute() throws Exception { Attribute attribute = new Attribute("name", "value"); List<Attribute> attributes = new ArrayList<>(); attributes.add(attribute); Attribute renamedAttribute = new Attribute("name", "newValue"); // Given given(element.getAttributes()).willReturn(attributes); given(modelProperties.renameAttribute(eq(attribute))).willReturn(renamedAttribute); given(mapperProperties.renameAttribute(eq(renamedAttribute))).willReturn(renamedAttribute); // When boolean ok = plugin.renameElementAttribute(element, "name"); // Then assertThat(ok).isTrue(); assertThat(attributes).hasSize(1); Attribute newAttribute = attributes.get(0); assertThat(newAttribute).isNotSameAs(attribute); assertThat(newAttribute).isSameAs(renamedAttribute); }
Example #12
Source File: AlterResultMapPluginTest.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
@Test public void shouldNotModifyResultMapAttributeIfTableDoesNotMatch() { String resultMapId = "someId"; List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(AlterResultMapPlugin.RESULT_MAP_ATTRIBUTE, resultMapId)); // Given given(introspectedTable.getFullyQualifiedTableNameAtRuntime()).willReturn("wrong_name"); // When plugin.renameResultMapAttribute(element, introspectedTable); // Then assertThat(attributes).hasSize(1); assertThat(attributes.get(0).getName()).isEqualTo(AlterResultMapPlugin.RESULT_MAP_ATTRIBUTE); assertThat(attributes.get(0).getValue()).isEqualTo(resultMapId); }
Example #13
Source File: OracelPageLimitPlugin.java From hui-mybatis-generator-plugins with Apache License 2.0 | 6 votes |
@Override public boolean sqlMapSelectByExampleWithBLOBsElementGenerated( XmlElement element, IntrospectedTable introspectedTable) { XmlElement isStart = new XmlElement("if"); isStart.addAttribute(new Attribute("test", "limitClauseStart != null and limitClauseStart >= 0")); isStart.addElement(new TextElement( "select * from (select t_1.*,rownum as row_num from (")); element.getElements().add(0, isStart); XmlElement isNotNullElement = new XmlElement("if"); isNotNullElement.addAttribute(new Attribute("test", "limitClauseStart != null and limitClauseStart >= 0")); isNotNullElement.addElement(new TextElement( " <![CDATA[ ) t_1 where rownum<=#{limitClauseCount,jdbcType=INTEGER} + #{limitClauseStart,jdbcType=INTEGER}) t_2 where t_2.row_num>#{limitClauseStart,jdbcType=INTEGER}]]>")); element.getElements().add(element.getElements().size(), isNotNullElement); return super.sqlMapUpdateByExampleWithoutBLOBsElementGenerated(element, introspectedTable); }
Example #14
Source File: AlterResultMapPluginTest.java From mybatis-generator-plugins with Apache License 2.0 | 6 votes |
@Test public void shouldModifyResultMapAttributeWhenTableMatches() { String resultMapId = "someId"; List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute("someName", "someValue")); attributes.add(new Attribute(AlterResultMapPlugin.RESULT_MAP_ATTRIBUTE, resultMapId)); // Given given(introspectedTable.getFullyQualifiedTableNameAtRuntime()).willReturn(TABLE_NAME); given(element.getAttributes()).willReturn(attributes); // When plugin.renameResultMapAttribute(element, introspectedTable); // Then assertThat(attributes).hasSize(2); assertThat(attributes.get(1).getName()).isEqualTo(AlterResultMapPlugin.RESULT_MAP_ATTRIBUTE); assertThat(attributes.get(1).getValue()).isEqualTo(RESULT_MAP_ID); }
Example #15
Source File: LimitPlugin.java From mybatis-generator-plugin with Apache License 2.0 | 6 votes |
/** * 生成limit节点 * @param element */ private void generateLimitElementWithExample(XmlElement element) { XmlElement ifLimitNotNullElement = new XmlElement("if"); ifLimitNotNullElement.addAttribute(new Attribute("test", "example != null and example.rows != null")); XmlElement ifOffsetNotNullElement = new XmlElement("if"); ifOffsetNotNullElement.addAttribute(new Attribute("test", "example.offset != null")); ifOffsetNotNullElement.addElement(new TextElement("limit ${example.offset}, ${example.rows}")); ifLimitNotNullElement.addElement(ifOffsetNotNullElement); XmlElement ifOffsetNullElement = new XmlElement("if"); ifOffsetNullElement.addAttribute(new Attribute("test", "example.offset == null")); ifOffsetNullElement.addElement(new TextElement("limit ${example.rows}")); ifLimitNotNullElement.addElement(ifOffsetNullElement); element.addElement(ifLimitNotNullElement); }
Example #16
Source File: ColumnRenamingRule.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
public XmlElement toXmlElement() { XmlElement xmlElement = new XmlElement("columnRenamingRule"); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute("searchString", searchString)); //$NON-NLS-1$ if (replaceString != null) { xmlElement.addAttribute(new Attribute( "replaceString", replaceString)); //$NON-NLS-1$ } return xmlElement; }
Example #17
Source File: XmlElementTools.java From mybatis-generator-plugin with Apache License 2.0 | 5 votes |
/** * 拷贝 * @param element * @return */ public static XmlElement clone(XmlElement element) { XmlElement destEle = new XmlElement(element.getName()); for (Attribute attribute : element.getAttributes()) { destEle.addAttribute(XmlElementTools.clone(attribute)); } for (Element ele : element.getElements()) { if (ele instanceof XmlElement) { destEle.addElement(XmlElementTools.clone((XmlElement) ele)); } else if (ele instanceof TextElement) { destEle.addElement(XmlElementTools.clone((TextElement) ele)); } } return destEle; }
Example #18
Source File: IgnoredColumn.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
/** * To xml element. * * @return the xml element */ public XmlElement toXmlElement() { XmlElement xmlElement = new XmlElement("ignoreColumn"); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute("column", columnName)); //$NON-NLS-1$ if (stringHasValue(configuredDelimitedColumnName)) { xmlElement.addAttribute(new Attribute( "delimitedColumnName", configuredDelimitedColumnName)); //$NON-NLS-1$ } return xmlElement; }
Example #19
Source File: AlterResultMapPlugin.java From mybatis-generator-plugins with Apache License 2.0 | 5 votes |
void renameResultMapAttribute(XmlElement element, IntrospectedTable introspectedTable) { if (tableMatches(introspectedTable)) { List<Attribute> attributes = element.getAttributes(); for (int i = 0; i < attributes.size(); i++) { Attribute attribute = attributes.get(i); if (RESULT_MAP_ATTRIBUTE.equals(attribute.getName())) { Attribute newAtt = new Attribute(RESULT_MAP_ATTRIBUTE, resultMapId); attributes.remove(i); attributes.add(newAtt); break; } } } }
Example #20
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 #21
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 #22
Source File: AbstractXmlElementGenerator.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
protected XmlElement getBaseColumnListElement() { XmlElement answer = new XmlElement("include"); //$NON-NLS-1$ answer.addAttribute(new Attribute("refid", //$NON-NLS-1$ introspectedTable.getIbatis2SqlMapNamespace() + "." + introspectedTable.getBaseColumnListId())); //$NON-NLS-1$ return answer; }
Example #23
Source File: PropertyHolder.java From mapper-generator-javafx with Apache License 2.0 | 5 votes |
protected void addPropertyXmlElements(XmlElement xmlElement) { Enumeration<?> enumeration = properties.propertyNames(); while (enumeration.hasMoreElements()) { String propertyName = (String) enumeration.nextElement(); XmlElement propertyElement = new XmlElement("property"); propertyElement.addAttribute(new Attribute("name", propertyName)); propertyElement.addAttribute(new Attribute( "value", properties.getProperty(propertyName))); xmlElement.addElement(propertyElement); } }
Example #24
Source File: OracleReturnKeyPlugin.java From hui-mybatis-generator-plugins with Apache License 2.0 | 5 votes |
/** * 返回主键方法 ==> 一般sql如下面 * <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> * SELECT currval('t_hui_order_id_seq') * </selectKey> * @param introspectedTable * @return */ private XmlElement addSelectKey(IntrospectedTable introspectedTable){ String resultType = introspectedTable.getPrimaryKeyColumns().get(0).getFullyQualifiedJavaType().getFullyQualifiedName(); String keyProperty = introspectedTable.getPrimaryKeyColumns().get(0).getActualColumnName(); String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime(); String sql = "SELECT " + tableName + "_SEQUENCE.nextval from dual')"; XmlElement selectKey = new XmlElement("selectKey"); TextElement selectKeySQL = new TextElement(sql); selectKey.addAttribute(new Attribute("keyProperty",keyProperty)); selectKey.addAttribute(new Attribute("order","BEFORE")); selectKey.addAttribute(new Attribute("resultType", resultType)); selectKey.addElement(selectKeySQL); return selectKey; }
Example #25
Source File: CommentGeneratorConfiguration.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
public XmlElement toXmlElement() { XmlElement answer = new XmlElement("commentGenerator"); //$NON-NLS-1$ if (getConfigurationType() != null) { answer.addAttribute(new Attribute("type", getConfigurationType())); //$NON-NLS-1$ } addPropertyXmlElements(answer); return answer; }
Example #26
Source File: AliasResultMapWithoutBLOBsElementGenerator.java From maven-archetype with GNU Lesser General Public License v2.1 | 5 votes |
/** * addElements: 在当前的parentElement元素中添加别名ReulstMap列元素. <br/> * * @author Hongbin Yuan 父元素,新的elements将作为子元素添加到该元素 * @param parentElement * @param introspectedTable 当前表的信息 * @since JDK 1.6 */ public void addElements(XmlElement parentElement,IntrospectedTable introspectedTable) { XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$ introspectedTable.getContext().getCommentGenerator().addComment(answer); answer.addAttribute(new Attribute("id", resultMapId)); String returnType = null; if (isSimple) { returnType = introspectedTable.getBaseRecordType(); } else { if (introspectedTable.getRules().generateBaseRecordClass()) { returnType = introspectedTable.getBaseRecordType(); } else { returnType = introspectedTable.getPrimaryKeyType(); } } answer.addAttribute(new Attribute("type", //$NON-NLS-1$ returnType)); if (introspectedTable.isConstructorBased()) { addResultMapConstructorElements(answer,introspectedTable); } else { addResultMapElements(answer,introspectedTable); } parentElement.addElement(answer); }
Example #27
Source File: GeneratedKey.java From mybatis-generator-core-fix with Apache License 2.0 | 5 votes |
/** * To xml element. * * @return the xml element */ public XmlElement toXmlElement() { XmlElement xmlElement = new XmlElement("generatedKey"); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute("column", column)); //$NON-NLS-1$ xmlElement.addAttribute(new Attribute( "sqlStatement", configuredSqlStatement)); //$NON-NLS-1$ if (stringHasValue(type)) { xmlElement.addAttribute(new Attribute("type", type)); //$NON-NLS-1$ } xmlElement.addAttribute(new Attribute("identity", //$NON-NLS-1$ isIdentity ? "true" : "false")); //$NON-NLS-1$ //$NON-NLS-2$ return xmlElement; }
Example #28
Source File: MySQLPageLimitPlugin.java From hui-mybatis-generator-plugins with Apache License 2.0 | 5 votes |
@Override public boolean sqlMapSelectByExampleWithBLOBsElementGenerated( XmlElement element, IntrospectedTable introspectedTable) { XmlElement isNotNullElement = new XmlElement("isNotNull"); isNotNullElement.addAttribute(new Attribute("property", "limitClauseStart")); isNotNullElement.addElement(new TextElement( " limit #limitClauseStart:INTEGER#, #limitClauseCount:INTEGER# ")); element.getElements().add(element.getElements().size(), isNotNullElement); return super.sqlMapUpdateByExampleWithoutBLOBsElementGenerated(element, introspectedTable); }
Example #29
Source File: RenameExampleClassAndMethodsPlugin.java From mybatis-generator-plugins with Apache License 2.0 | 5 votes |
boolean renameElement(XmlElement element) { for (int i = 0; i < element.getAttributes().size(); i++) { Attribute attribute = element.getAttributes().get(i); if (XML_ID_ATTRIBUTE.equals(attribute.getName())) { String oldValue = attribute.getValue(); Matcher matcher = classMethodPattern.matcher(oldValue); String newValue = matcher.replaceAll(classMethodReplaceString); Attribute newAtt = new Attribute(attribute.getName(), newValue); element.getAttributes().set(i, newAtt); } } return true; }
Example #30
Source File: XMLMapperGenerator.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
protected XmlElement getSqlMapElement() { FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable(); progressCallback.startTask(getString( "Progress.12", table.toString())); //$NON-NLS-1$ XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$ String namespace = introspectedTable.getMyBatis3SqlMapNamespace(); answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$ namespace)); context.getCommentGenerator().addRootComment(answer); addResultMapWithoutBLOBsElement(answer); addResultMapWithBLOBsElement(answer); addExampleWhereClauseElement(answer); addMyBatis3UpdateByExampleWhereClauseElement(answer); addBaseColumnListElement(answer); addBlobColumnListElement(answer); addSelectByExampleWithBLOBsElement(answer); addSelectByExampleWithoutBLOBsElement(answer); addSelectByPrimaryKeyElement(answer); addDeleteByPrimaryKeyElement(answer); addDeleteByExampleElement(answer); addInsertElement(answer); addInsertSelectiveElement(answer); addCountByExampleElement(answer); addUpdateByExampleSelectiveElement(answer); addUpdateByExampleWithBLOBsElement(answer); addUpdateByExampleWithoutBLOBsElement(answer); addUpdateByPrimaryKeySelectiveElement(answer); addUpdateByPrimaryKeyWithBLOBsElement(answer); addUpdateByPrimaryKeyWithoutBLOBsElement(answer); return answer; }