Thursday, 3 October 2013

Programmatically Insert New Row in DB using View Object reference

We have seen declarative approach to insert new row in database.

In this post i will explain you how to insert new row Programmatically.

1. Create the AppModuleImpl class and also create the java class for respective ViewObject. In this example i am working on EmployeeView. So i have generated EmploueeViewImpl java class.

2. Create the user defined method in AppModuleImple calss as shown below.

    public void createNewRow(){

//get he EmployeeViewImpl class instance
        EmployeesViewImpl vo=this.getEmployeesView1();

       // Create new row to insert data
        Row r=vo.createRow();
//Set the values to respective attributes.
            r.setAttribute("EmployeeId", 509);
            r.setAttribute("FirstName", "test");
            r.setAttribute("LastName", "test");
            r.setAttribute("Email", "");
            r.setAttribute("PhoneNumber", "800000444");
            r.setAttribute("HireDate", new Timestamp(System.currentTimeMillis()));
            r.setAttribute("JobId", "IT_PROG");
            r.setAttribute("Salary", 5000);
            r.setAttribute("CommissionPct", "");
            r.setAttribute("ManagerId", "");
            r.setAttribute("DepartmentId", 340);
//insert row in the view object
//commit the transaction


  1. Hi,
    Thanks for the Post.
    I have executed the same but it is generating some error " JBO-28201: Post threshold limit reached. Some entities yet to be posted.
    " and row is not getting inserted in the DB.

    Please suggest.