(我想实现拦截所有更新语句,然后自动补充上updateDateTime(当前时间)和updateBy(当前用户),由于实体中包含了这两个字段,所以我下面的操作会导致执行更新操作时的出现列重复),请问下有什么办法可以实现吗)
if (st.isUpdate() && st instanceof NutPojo) {
NutPojo np = (NutPojo) st;
List<PItem> items = null;
try {
items = (ArrayList<PItem>) itemField.get(np);
for (int i = 0; i < items.size(); i++) {
if (items.get(i) instanceof UpdateFieldsPItem) {
String uname = null;
Subject subject = SecurityUtils.getSubject();
if (subject != null) {
uname = (String) subject.getSession().getAttribute(UserName.SessionUserName);
}
items.add(i + 1, new Static(
", updatetime = SYSDATE, updateby = " + ((null == uname) ? null : "'" + uname + "'")));
break;
}
}