Friday, 20 December 2013

Generate the DB sequence number without loosing

Generally we use sequence number in EntityImpl class create() method using the following code

       SequenceImpl seq=new SequenceImpl("EMPLOYEES_SEQ",getDBTransaction());

or we will set expression in default attribute of Entity Object xml file. If we follow this approach we will loose the sequence numbers. To avoid this use the following approach

Step 1: Go to entity object xml file  --> select the EmployeeID -- > go to defalu value and set -999 or -9999. Because the sequence number never reach the negetive value.

Step 2: Generate the java class for EO and override the doDML() method

    protected void doDML(int operation, TransactionEvent e) {
            SequenceImpl seq=new SequenceImpl("EMPLOYEES_SEQ",getDBTransaction());
        super.doDML(operation, e);
Step 3: Run the application

No comments:

Post a Comment