Hi Everyone in this post i will describe how to auto insert Primary key in ADF , The key will be save before commit , means when ever a user enter a new record and hit save , the primary key will automatically append with the new record and save in database
For this post i use Departments table
So to insert Primary key automatically just Run your jdeveloper and create a new Application and
create Departments Entity object and View object , if you don't know how to create new Application please click on following link
http://adfindepth.blogspot.com/2016/05/how-to-start-with-adf.html
After creating Application the first step is generate DepartmentsImpl class
just double click on Departments Entity object , then click on java Tap , and then click on Edit java option
Now check the box "Generate Entity Object Class" and also make sure that check boxes are checked for
Accessors
Data Manipulation Method
Create Method
Remove Method
After checked all the five check boxes click on OK
Now click on the link to open the DepartmentsImpl class
Now at the end of DepartmentsImpl class create a method to generate Max Id
After creating maxId method , modify the doDML method , in the following way
(Note :- ADF Framework automatically created doDML method when you generate DepartmentsImpl class , you just need to modify it according to your requirement)
After modifying doDML method just click on save
Now double click on Departments Entity Object and click on attributes ,
Then select DepartmentId and unchecked Mandatory
Again click on save all , and Right click on AppModule and select Run
Now double click on DepartmentsView1 and click on + sign
After clicking on + sign , you can enter new record ,
Fill DepartmentName
ManagerId
and LocationId
but do not enter any value for DepartmentId (it will automatically save)
After insert three values then click on "save change to database" (commit)
After clicking on "save change to database"(commit)
you will see this view
For this post i use Departments table
So to insert Primary key automatically just Run your jdeveloper and create a new Application and
create Departments Entity object and View object , if you don't know how to create new Application please click on following link
http://adfindepth.blogspot.com/2016/05/how-to-start-with-adf.html
After creating Application the first step is generate DepartmentsImpl class
just double click on Departments Entity object , then click on java Tap , and then click on Edit java option
Now check the box "Generate Entity Object Class" and also make sure that check boxes are checked for
Accessors
Data Manipulation Method
Create Method
Remove Method
After checked all the five check boxes click on OK
Now click on the link to open the DepartmentsImpl class
Now at the end of DepartmentsImpl class create a method to generate Max Id
After creating maxId method , modify the doDML method , in the following way
(Note :- ADF Framework automatically created doDML method when you generate DepartmentsImpl class , you just need to modify it according to your requirement)
After modifying doDML method just click on save
Now double click on Departments Entity Object and click on attributes ,
Then select DepartmentId and unchecked Mandatory
Again click on save all , and Right click on AppModule and select Run
Now double click on DepartmentsView1 and click on + sign
After clicking on + sign , you can enter new record ,
Fill DepartmentName
ManagerId
and LocationId
but do not enter any value for DepartmentId (it will automatically save)
After insert three values then click on "save change to database" (commit)
you will see this view
Please Feel Free To Ask if you Face any Difficulty
Like and share to help others
Thanks
Date 15-06-2016
I appreciate your good work here just want to suggest that it would be more helping if you can past the coding here so we can copy. it would really help us.
ReplyDeleteits really useful thanks
ReplyDeleteIts realyy very helpfull Thanks for it
ReplyDelete