Google Analytics

Wednesday, September 18, 2013

ADF - Find duplicate records when commit


   public void postChanges(TransactionEvent te)
    {
        try
        {
          super.postChanges(te);
        }
        catch (DMLConstraintException ex)
        {
          Row r = ex.getEntityRow();
          AttributeDef attrs[] = r.getStructureDef().getAttributeDefs();
          int numAttrs = attrs.length;
          String msg = "Duplicate record found. Please remove: ";
          for (int i = 0; i < numAttrs; i++)
          {
            if (attrs[i].isPrimaryKey()){
              msg = msg + r.getAttribute(i+1).toString() + " record from file and retry!";
            }
            throw new JboException(msg);
          }
       }
    }
   
More about postChanges method refer:
http://docs.oracle.com/cd/E14571_01/apirefs.1111/e10653/oracle/jbo/server/EntityImpl.html#postChanges %28oracle.jbo.server.TransactionEvent%29