Wednesday, February 20, 2013

Different ways of setting Sequence Number in ADF

1. In EmployeesEO, change the type of EmployeeID to be Number, Default Value to be Expression, and set the value as
(new oracle.jbo.server.SequenceImpl("HR.EMPLOYEES_SEQ", adf.object.getDBTransaction())).getSequenceNumber()

2. Override the create() in EmployeesEOImpl class as follows:
    protected void create(AttributeList attributeList) {
        super.create(attributeList);
        SequenceImpl seq = new SequenceImpl("EMPLOYEES_SEQ", getDBTransaction());
        Number seqNextval = seq.getSequenceNumber();
        setEmployeeId(seqNextval);
    }

3. Override the initDefaults() in EmployeesEOImpl class as follows:
    protected void initDefaults() {
        super.initDefaults();
        SequenceImpl sequence = new SequenceImpl("EMPLOYEES_SEQ", getDBTransaction());
        DBSequence seqNextval = new DBSequence(sequence.getSequenceNumber());
    }

No comments:

Post a Comment