Oracle Forms to ADF & JET Migration
Free Estimation
Toggle Bar

Setting sequence numbers in ADF

It is advisable to use sequence number for each ADF BC Entity object and there need to be corresponding sequence number created for each database table in DB.

It is known as ‘Surrogate Key’ or ‘Primary Key’ of ADF BC.

There are various way of populating this key for ADF BC component and I am trying to give few of best practices.

1. Using Create() method of entity

There is create method in BC Entity Object that can be overidden to assign primary key. Go to java tab for ADF BC entity object and generate this java class and don’t forget to select Create Method check box.



After that go to and search for create method and write the following statement of SequenceImpl




Disadvantage of this way is ,if transaction is rollback then sequence number is lost.


2.  Using DB Trigger

we can use DB trigger to assign the sequence to departmentid and the advantage of this usage is we will retain the sequence number even after transaction is rollback.


Go to department Entity object and set the department id to DbSequence.


Set Updatable to Never since we will not allow user to edit this value


Set refresh after to update because when we use trigger and create row ADF BC will automatically assign negative value to Department id and when we press commit then only it will run trigger and assign value to dept id.


That is why we will not loose sequence number when we do rollback.




Create Trigger using Declarative way


Create a trigger for Department id sequence , there is no need to write trigger ,it can be automatically created by jdeveloper.




Select the following




then select the sql tab and you will see that jdeveloper has automatically created trigger definition for you.






Now run appmodule and create department row and we will see that negative value is assigned to department id.




When we press commit it will generate department id and if we press rollback nothing happens and negative value is rollback instead of sequence number.


3. Using Groovy to generate sequence number.


Here we can write custom method in in custom entity impl class that will be implemented by


don’t forget to select the expression.




adf.object.customMethodName(“SEQ_NAME”) – This method will call generic custom method name that will return the sequence number.




customMethodName definition will be same as point number one except it prototype will be


customMethodName(String SeqNumber){


//call step one code and return sequence number.




4. Fourth way is most easiest and no code required.


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



How to attach security to adf bc web services – AD...
How to expose custom AM method as a webservice in ...


No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Sunday, 05 July 2020
If you'd like to register, please fill in the username, password and name fields.

Captcha Image

Support is currently Offline

Latest Posts


Cron Job Starts