【发布时间】:2014-05-22 13:56:37
【问题描述】:
我对推土机如何将源对象映射到目标对象感到困惑。我有以下情况:
源对象:
public class Rule {
private String id;
private String name;
private String group;
private String content;
private RuleType ruleType;
private String drlContent;
private boolean enabled;
private Strategy strategy;
// getters and setters
}
目标对象:
public class RuleActivity {
private String id;
private String name;
private Strategy strategy;
// getters and setters
}
XML 映射:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<stop-on-errors>true</stop-on-errors>
<date-format>MM/dd/yyyy HH:mm</date-format>
</configuration>
<mapping wildcard="false">
<class-a>com.magick.models.shared.Rule</class-a>
<class-b>com.magick.models.shared.log.RuleActivity</class-b>
<field>
<a>id</a>
<b>ruleId</b>
</field>
<field>
<a>strategy.name</a>
<b>strategy.name</b>
</field>
<field>
<a>name</a>
<b>name</b>
</field>
</mapping>
现在这些将如何映射?我的意思是,目标对象是否包含完整的策略对象或仅包含它的 strategy.name 字段。
【问题讨论】: