How to track the row changes in ADF

Requirement:  Want to store the old value of attribute in some other table if user change it.

Solution : Define EntityImpl Class. Override the doDML() method of the same entity.

Define EntityDefImpl Class of another entity though which preserve the changes in some another table.

Please see below code

    protected void doDML(int operation, TransactionEvent e) {
        super.doDML(operation, e);
        if(operation==DML_INSERT){
          System.out.println("DML INSERT");  
        }
        if(operation==DML_UPDATE){
            System.out.println("Update operation");
            System.out.println("-1-");
            String entityName = "yash.hr.model.eo.EmpAudit";
            System.out.println("-2-");
            EntityDefImpl deptDef = EntityDefImpl.findDefObject(entityName);
            System.out.println("-3-");
            EntityImpl newDept = deptDef.createInstance2(getDBTransaction(), null); System.out.println("-4-");
            newDept.setAttribute("EmpId", getEmployeeId());
            newDept.setAttribute("EmpName", getFirstName()+getLastName());
            newDept.setAttribute("Salary", getPostedAttribute(7));
            System.out.println("-5-");
            try{
          //  getDBTransaction().commit();
            System.out.println("try");
            }catch(JboException ex){
            System.out.println("try");
            throw ex;
            }
            System.out.println("Update operation");
        }
    }


this will create new row in EmpAudit EO and after commit it will post the row in DB.

Thanks.

Comments

Popular posts from this blog

React JS

WaterMark behavior in ADF

WebLogic Application Deployment & Shared Library