您的位置:首页 > 编程语言 > Java开发

Monitor the changes in EOImpl.java side

2016-03-16 10:11 477 查看
You can override the doDML method and get the changes before call super.doDML();

Code with example:

@Override
protected void doDML(int operation, TransactionEvent event) {
if (operation == DML_UPDATE) {
final String ORDER_ID = "OrderId";
// get posted value of OrderId attribute
// this method is to get the old value before change
Object oldOrderId = getPostedAttribute(this.getAttributeIndexOf(ORDER_ID));
// get value of OrderId after change
Object newOrderId = this.getAttribute(ORDER_ID);
// compare and take some action based on the results of comparison
if (newOrderId != null && newOrderId.equals(oldOrderId)) {
//do sth. here
//System.out.println("Order Id changed from " + oldOrdreId + " to " + newOrderId);
}
// finally calling super.doDML()
super.doDML(operation, event);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: