Thursday, February 7, 2013

Pre-Populate Primary Key Value thru EOImpl when creating a new row in adf


 import oracle.jbo.server.SequenceImpl;
// include create method while creating EOImpl

 protected void create(AttributeList attributeList) {
        super.create(attributeList);
        SequenceImpl sequence=new SequenceImpl("Table_Seq",getDBTransaction());
                setPrimaryKeyId(sequence.getSequenceNumber());
            // This sets the primary key value for the newly created row
    }


One more way to create a sequence using Database Trigger:
http://sathyam-soa.blogspot.com/2012/07/adf-db-sequence-using-db-trigger.html


Another way is to

Have this expression defined at EO Attribute - >

(new oracle.jbo.server.SequenceImpl("Table_SEQ",adf.object.
getDBTransaction())).getSequenceNumber()

https://tompeez.wordpress.com/2011/09/02/using-groovy-expression-to-set-a-primary-key-with-a-sequence-number/

No comments: