1 Reply Latest reply: Sep 7, 2013 7:08 AM by oladslw RSS

    composite primary key in adf

    sureshkb25

      Hi,

        Please explain  how can I set a primary key ( with composite key, say fyear(7), voucher_no number(5),voucher_sub_no number(2)) for a new record in ADF  using programming..

      Thanks in advance

       

      Suresh

        • 1. Re: composite primary key in adf
          oladslw

          If you are using entitybased view objects in your ADF bc, you can have multiple primarykeys set in the entity object, even if your underlying database table doesn't use composite primarykeys.

          The ADF framework will take care of the post behavior using the default postchanges implementation. The sequence of values posted may be based on the Order of the primary keys, usually can be visually inspected by the sequence in your attributes listing.

           

          However the default postchanges() behavior can be overridden e.g.

           

          public class CompositePKPositingEOImpl extends EntityImpl {

              @Override

              public void postChanges(TransactionEvent transactionEvent) {

                  if (this.getPostState() == STATUS_NEW) {

                   

                     this.setFyear(x);

                    this.setVoucherNo(this.getFYear()/this.getVoucherNo());

                    this.setVoucherSubNumber(txyz);

                  }

                  // TODO Implement this method

                  super.postChanges(transactionEvent);

              }

           

           

          or checkout the discussion

           

          https://forums.oracle.com/thread/622398