// 替换所有条件parameterClass中的pojoExample
List<Element> list = document.getRootElement().getElements();
logger.info(list.size() + "");
for (int i = 0; i < list.size(); i++) {
XmlElement xml = (XmlElement) list.get(i);
String content = xml.getFormattedContent(0);
if (content.contains(introspectedTable.getExampleType())) {
List<Attribute> attrs = xml.getAttributes();
for (int j = 0; j < attrs.size(); j++) {
if (attrs.get(j).getName().equals("parameterClass")) {
attrs.get(j).setValue(criteria.getFullyQualifiedName());
}
}
}
}
// Example_Where_Clause
XmlElement Where_Clause = (XmlElement) document.getRootElement().getElements().get(1);
// 移除第一个
Where_Clause.removeElement(0);
StringBuilder sb = new StringBuilder();
XmlElement dynamicElement = new XmlElement("dynamic"); //$NON-NLS-1$
dynamicElement.addAttribute(new Attribute("prepend", "where")); //$NON-NLS-1$ //$NON-NLS-2$
Where_Clause.addElement(dynamicElement);
for (IntrospectedColumn introspectedColumn : introspectedTable.getNonPrimaryKeyColumns()) {
XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
isNotNullElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
isNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty("condition."))); //$NON-NLS-1$
dynamicElement.addElement(isNotNullElement);
sb.setLength(0);
sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn));
sb.append(" = "); //$NON-NLS-1$
sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn, "condition."));
isNotNullElement.addElement(new TextElement(sb.toString()));
}
return true;
}