Sometime we need to manully assign a new value to a sequence column. For example, we have a department table with primary key column department_id, which is based on a sequence "department_sequence".
When we try to create a new record in the department table, we will do the following in the AMImpl.java:
*************************************************************
DepartmentVOImpl vo = getDepartmentVOImpl();
vo.clearCache();
Row row = vo.createRow();
SequenceImpl sequence = new SequenceImpl("department_sequence, getDBTransaction());
Number dept_id = sequence.getSequenceNumber();
row.setAttribute("DepartmentId", dept_id);
//set other attribute values...
vo.insertRow(row);
getDBTransaction().commit();
*************************************************************
When we try to create a new record in the department table, we will do the following in the AMImpl.java:
*************************************************************
DepartmentVOImpl vo = getDepartmentVOImpl();
vo.clearCache();
Row row = vo.createRow();
SequenceImpl sequence = new SequenceImpl("department_sequence, getDBTransaction());
Number dept_id = sequence.getSequenceNumber();
row.setAttribute("DepartmentId", dept_id);
//set other attribute values...
vo.insertRow(row);
getDBTransaction().commit();
*************************************************************
Comments