本文整理匯總了Java中org.mybatis.generator.api.dom.xml.XmlElement.addElement方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlElement.addElement方法的具體用法?Java XmlElement.addElement怎麽用?Java XmlElement.addElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mybatis.generator.api.dom.xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.addElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
@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);
}
}
示例2: sqlMapSelectByExampleWithoutBLOBsElementGenerated
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
/**
* 為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;
}
示例3: addElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
@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.Long")); //$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);
}
}
示例4: getSelectKey
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
/**
* 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
*/
public static Element getSelectKey(IntrospectedColumn introspectedColumn, GeneratedKey generatedKey) {
String identityColumnType = introspectedColumn
.getFullyQualifiedJavaType().getFullyQualifiedName();
XmlElement answer = new XmlElement("selectKey");
answer.addAttribute(new Attribute("resultType", identityColumnType));
answer.addAttribute(new Attribute(
"keyProperty", introspectedColumn.getJavaProperty()));
answer.addAttribute(new Attribute("order",
generatedKey.getMyBatis3Order()));
answer.addElement(new TextElement(generatedKey
.getRuntimeSqlStatement()));
return answer;
}
示例5: addCdataNode2
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
private void addCdataNode2(CommentGenerator commentGenerator, XmlElement parentElement) {
XmlElement answer = new XmlElement("select");
answer.addAttribute(new Attribute("id", "selectWithCdata2"));
commentGenerator.addComment(answer);
answer.addElement(new TextElement("select foo from bar where foo <![CDATA[ < ]]> 22"));
parentElement.addElement(answer);
}
示例6: getExampleIncludeElement
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
protected XmlElement getExampleIncludeElement() {
XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
ifElement.addAttribute(new Attribute("test", "_parameter != null")); //$NON-NLS-1$ //$NON-NLS-2$
XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
introspectedTable.getExampleWhereClauseId()));
ifElement.addElement(includeElement);
return ifElement;
}
示例7: addCdataNode1
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
private void addCdataNode1(CommentGenerator commentGenerator, XmlElement parentElement) {
XmlElement answer = new XmlElement("select");
answer.addAttribute(new Attribute("id", "selectWithCdata1"));
commentGenerator.addComment(answer);
answer.addElement(new TextElement("<![CDATA["));
answer.addElement(new TextElement("select foo from bar where foo < 22"));
answer.addElement(new TextElement("]]>"));
parentElement.addElement(answer);
}
示例8: addComment
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
/**
* Adds a suitable comment to warn users that the element was generated, and when it was generated.
*
* @param xmlElement
* the xml element
*/
public void addComment(XmlElement xmlElement) {
if (suppressAllComments) {
return;
}
xmlElement.addElement(new TextElement("<!--")); //$NON-NLS-1$
StringBuilder sb = new StringBuilder();
sb.append(" WARNING - "); //$NON-NLS-1$
sb.append(MergeConstants.NEW_ELEMENT_TAG);
xmlElement.addElement(new TextElement(sb.toString()));
xmlElement
.addElement(new TextElement(
" This element is automatically generated by MyBatis Generator, do not modify.")); //$NON-NLS-1$
String s = getDateString();
if (s != null) {
sb.setLength(0);
sb.append(" This element was generated on "); //$NON-NLS-1$
sb.append(s);
sb.append('.');
xmlElement.addElement(new TextElement(sb.toString()));
}
xmlElement.addElement(new TextElement("-->")); //$NON-NLS-1$
}
示例9: addPropertyXmlElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
protected void addPropertyXmlElements(XmlElement xmlElement) {
Enumeration<?> enumeration = properties.propertyNames();
while (enumeration.hasMoreElements()) {
String propertyName = (String) enumeration.nextElement();
XmlElement propertyElement = new XmlElement("property"); //$NON-NLS-1$
propertyElement.addAttribute(new Attribute("name", propertyName)); //$NON-NLS-1$
propertyElement.addAttribute(new Attribute(
"value", properties.getProperty(propertyName))); //$NON-NLS-1$
xmlElement.addElement(propertyElement);
}
}
示例10: addElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$
answer.addAttribute(new Attribute("id", //$NON-NLS-1$
introspectedTable.getBlobColumnListId()));
context.getCommentGenerator().addComment(answer);
StringBuilder sb = new StringBuilder();
Iterator<IntrospectedColumn> iter = introspectedTable.getBLOBColumns()
.iterator();
while (iter.hasNext()) {
sb.append(MyBatis3FormattingUtilities.getSelectListPhrase(iter
.next()));
if (iter.hasNext()) {
sb.append(", "); //$NON-NLS-1$
}
if (sb.length() > 80) {
answer.addElement(new TextElement(sb.toString()));
sb.setLength(0);
}
}
if (sb.length() > 0) {
answer.addElement(new TextElement(sb.toString()));
}
if (context.getPlugins().sqlMapBlobColumnListElementGenerated(
answer, introspectedTable)) {
parentElement.addElement(answer);
}
}
示例11: addElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
boolean useColumnIndex = isTrue(introspectedTable
.getTableConfigurationProperty(PropertyRegistry.TABLE_USE_COLUMN_INDEXES));
XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$
answer.addAttribute(new Attribute("id", //$NON-NLS-1$
introspectedTable.getBaseResultMapId()));
String returnType;
if (introspectedTable.getRules().generateBaseRecordClass()) {
returnType = introspectedTable.getBaseRecordType();
} else {
returnType = introspectedTable.getPrimaryKeyType();
}
answer.addAttribute(new Attribute("class", //$NON-NLS-1$
returnType));
context.getCommentGenerator().addComment(answer);
int i = 1;
if (stringHasValue(introspectedTable
.getSelectByPrimaryKeyQueryId())
|| stringHasValue(introspectedTable
.getSelectByExampleQueryId())) {
i++;
}
for (IntrospectedColumn introspectedColumn : introspectedTable
.getNonBLOBColumns()) {
XmlElement resultElement = new XmlElement("result"); //$NON-NLS-1$
if (useColumnIndex) {
resultElement.addAttribute(new Attribute(
"columnIndex", Integer.toString(i++))); //$NON-NLS-1$
} else {
resultElement
.addAttribute(new Attribute(
"column", Ibatis2FormattingUtilities.getRenamedColumnNameForResultMap(introspectedColumn))); //$NON-NLS-1$
}
resultElement.addAttribute(new Attribute(
"property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
resultElement.addAttribute(new Attribute("jdbcType", //$NON-NLS-1$
introspectedColumn.getJdbcTypeName()));
if (stringHasValue(introspectedColumn
.getTypeHandler())) {
resultElement.addAttribute(new Attribute(
"typeHandler", introspectedColumn.getTypeHandler())); //$NON-NLS-1$
}
answer.addElement(resultElement);
}
if (context.getPlugins()
.sqlMapResultMapWithoutBLOBsElementGenerated(answer,
introspectedTable)) {
parentElement.addElement(answer);
}
}
示例12: toXmlElement
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
/**
* Builds an XmlElement representation of this context. Note that the XML
* may not necessarily validate if the context is invalid. Call the
* <code>validate</code> method to check validity of this context.
*
* @return the XML representation of this context
*/
public XmlElement toXmlElement() {
XmlElement xmlElement = new XmlElement("context"); //$NON-NLS-1$
xmlElement.addAttribute(new Attribute("id", id)); //$NON-NLS-1$
if (defaultModelType != ModelType.CONDITIONAL) {
xmlElement.addAttribute(new Attribute(
"defaultModelType", defaultModelType.getModelType())); //$NON-NLS-1$
}
if (stringHasValue(introspectedColumnImpl)) {
xmlElement.addAttribute(new Attribute(
"introspectedColumnImpl", introspectedColumnImpl)); //$NON-NLS-1$
}
if (stringHasValue(targetRuntime)) {
xmlElement.addAttribute(new Attribute(
"targetRuntime", targetRuntime)); //$NON-NLS-1$
}
addPropertyXmlElements(xmlElement);
for (PluginConfiguration pluginConfiguration : pluginConfigurations) {
xmlElement.addElement(pluginConfiguration.toXmlElement());
}
if (commentGeneratorConfiguration != null) {
xmlElement.addElement(commentGeneratorConfiguration.toXmlElement());
}
if (jdbcConnectionConfiguration != null) {
xmlElement.addElement(jdbcConnectionConfiguration.toXmlElement());
}
if (connectionFactoryConfiguration != null) {
xmlElement.addElement(connectionFactoryConfiguration.toXmlElement());
}
if (javaTypeResolverConfiguration != null) {
xmlElement.addElement(javaTypeResolverConfiguration.toXmlElement());
}
if (javaModelGeneratorConfiguration != null) {
xmlElement.addElement(javaModelGeneratorConfiguration
.toXmlElement());
}
if (sqlMapGeneratorConfiguration != null) {
xmlElement.addElement(sqlMapGeneratorConfiguration.toXmlElement());
}
if (javaClientGeneratorConfiguration != null) {
xmlElement.addElement(javaClientGeneratorConfiguration.toXmlElement());
}
for (TableConfiguration tableConfiguration : tableConfigurations) {
xmlElement.addElement(tableConfiguration.toXmlElement());
}
return xmlElement;
}
示例13: addElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
answer
.addAttribute(new Attribute(
"id", introspectedTable.getSelectByExampleWithBLOBsStatementId())); //$NON-NLS-1$
answer.addAttribute(new Attribute(
"resultMap", introspectedTable.getResultMapWithBLOBsId())); //$NON-NLS-1$
answer.addAttribute(new Attribute(
"parameterClass", introspectedTable.getExampleType())); //$NON-NLS-1$
context.getCommentGenerator().addComment(answer);
answer.addElement(new TextElement("select")); //$NON-NLS-1$
XmlElement isParameterPresent = new XmlElement("isParameterPresent"); //$NON-NLS-1$
XmlElement isEqualElement = new XmlElement("isEqual"); //$NON-NLS-1$
isEqualElement.addAttribute(new Attribute("property", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
isEqualElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
isParameterPresent.addElement(isEqualElement);
answer.addElement(isParameterPresent);
StringBuilder sb = new StringBuilder();
if (stringHasValue(introspectedTable
.getSelectByExampleQueryId())) {
sb.append('\'');
sb.append(introspectedTable.getSelectByExampleQueryId());
sb.append("' as QUERYID,"); //$NON-NLS-1$
answer.addElement(new TextElement(sb.toString()));
}
answer.addElement(getBaseColumnListElement());
answer.addElement(new TextElement(",")); //$NON-NLS-1$
answer.addElement(getBlobColumnListElement());
sb.setLength(0);
sb.append("from "); //$NON-NLS-1$
sb.append(introspectedTable
.getAliasedFullyQualifiedTableNameAtRuntime());
answer.addElement(new TextElement(sb.toString()));
XmlElement isParameterPresenteElement = new XmlElement(
"isParameterPresent"); //$NON-NLS-1$
answer.addElement(isParameterPresenteElement);
XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
introspectedTable.getIbatis2SqlMapNamespace()
+ "." + introspectedTable.getExampleWhereClauseId())); //$NON-NLS-1$
isParameterPresenteElement.addElement(includeElement);
XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
isNotNullElement
.addAttribute(new Attribute("property", "orderByClause")); //$NON-NLS-1$ //$NON-NLS-2$
isNotNullElement
.addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$
isParameterPresenteElement.addElement(isNotNullElement);
if (context.getPlugins()
.sqlMapSelectByExampleWithBLOBsElementGenerated(answer,
introspectedTable)) {
parentElement.addElement(answer);
}
}
開發者ID:nextyu,項目名稱:summer-mybatis-generator,代碼行數:65,代碼來源:SelectByExampleWithBLOBsElementGenerator.java
示例14: addElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
answer.addAttribute(new Attribute("id", //$NON-NLS-1$
introspectedTable.getUpdateByExampleWithBLOBsStatementId()));
answer.addAttribute(new Attribute("parameterType", "map")); //$NON-NLS-1$ //$NON-NLS-2$
context.getCommentGenerator().addComment(answer);
StringBuilder sb = new StringBuilder();
sb.append("update "); //$NON-NLS-1$
sb.append(introspectedTable
.getAliasedFullyQualifiedTableNameAtRuntime());
answer.addElement(new TextElement(sb.toString()));
// set up for first column
sb.setLength(0);
sb.append("set "); //$NON-NLS-1$
Iterator<IntrospectedColumn> iter = ListUtilities.removeGeneratedAlwaysColumns(introspectedTable.getAllColumns())
.iterator();
while (iter.hasNext()) {
IntrospectedColumn introspectedColumn = iter.next();
sb.append(MyBatis3FormattingUtilities
.getAliasedEscapedColumnName(introspectedColumn));
sb.append(" = "); //$NON-NLS-1$
sb.append(MyBatis3FormattingUtilities.getParameterClause(
introspectedColumn, "record.")); //$NON-NLS-1$
if (iter.hasNext()) {
sb.append(',');
}
answer.addElement(new TextElement(sb.toString()));
// set up for the next column
if (iter.hasNext()) {
sb.setLength(0);
OutputUtilities.xmlIndent(sb, 1);
}
}
answer.addElement(getUpdateByExampleIncludeElement());
if (context.getPlugins()
.sqlMapUpdateByExampleWithBLOBsElementGenerated(answer,
introspectedTable)) {
parentElement.addElement(answer);
}
}
示例15: addElements
import org.mybatis.generator.api.dom.xml.XmlElement; //導入方法依賴的package包/類
@Override
public void addElements(XmlElement parentElement) {
XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
answer
.addAttribute(new Attribute(
"id", introspectedTable.getUpdateByExampleSelectiveStatementId())); //$NON-NLS-1$
context.getCommentGenerator().addComment(answer);
StringBuilder sb = new StringBuilder();
sb.append("update "); //$NON-NLS-1$
sb.append(introspectedTable
.getAliasedFullyQualifiedTableNameAtRuntime());
answer.addElement(new TextElement(sb.toString()));
XmlElement dynamicElement = new XmlElement("dynamic"); //$NON-NLS-1$
dynamicElement.addAttribute(new Attribute("prepend", "set")); //$NON-NLS-1$ //$NON-NLS-2$
answer.addElement(dynamicElement);
for (IntrospectedColumn introspectedColumn : introspectedTable
.getAllColumns()) {
XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
isNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
isNotNullElement.addAttribute(new Attribute(
"property", introspectedColumn.getJavaProperty("record."))); //$NON-NLS-1$ //$NON-NLS-2$
dynamicElement.addElement(isNotNullElement);
sb.setLength(0);
sb.append(Ibatis2FormattingUtilities
.getAliasedEscapedColumnName(introspectedColumn));
sb.append(" = "); //$NON-NLS-1$
sb.append(Ibatis2FormattingUtilities.getParameterClause(
introspectedColumn, "record.")); //$NON-NLS-1$
isNotNullElement.addElement(new TextElement(sb.toString()));
}
XmlElement isParameterPresentElement = new XmlElement(
"isParameterPresent"); //$NON-NLS-1$
answer.addElement(isParameterPresentElement);
XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
introspectedTable.getIbatis2SqlMapNamespace()
+ "." + introspectedTable.getExampleWhereClauseId())); //$NON-NLS-1$
isParameterPresentElement.addElement(includeElement);
if (context.getPlugins()
.sqlMapUpdateByExampleSelectiveElementGenerated(answer,
introspectedTable)) {
parentElement.addElement(answer);
}
}