Sunday, 10 January 2016

Sequences

There are two options for applying a sequence:
  • Code using SequenceImpl
Pseudo code:
  ViewImpl.java -> create method -> getDBTransaction -> SequenceImpl -> DepartmentsImpl.setDepartmentId

protected void create(AttributeList attributeList){
  super.create(attributeList);
  SequenceImpl seq = new SequenceImpl("DEPARTMENTS_SEQ",getDBTransaction());
  setDepartmentId(seq.getSequenceNumber());
}

  • Using DBSequence 
    • Sequence is assigned on commiting the data
    • Attribute needs to know the value will be assigned "later"
      •  Create a trigger on the table(employees table)
        • Provide name, sequence and the column into which the value has to be set
      • Navigate to EmployeesEO, set the EmployeeId  type as "DBSequence", and set 'refresh after update' to yes.

No comments:

Post a Comment