Wednesday, July 29, 2015

JDeveloper Memory And Performance

As a general rule, Java is optimized for throughput, not latency. Once the garbage collector kicks in, performance drops like a rock. A 2 second pause every once in a while is OK for a server, but for an IDE it's misery. So here's the fix:


  1. Go to your JDeveloper root directory, is should be something like C:\Oracle\jdev\Middleware\jdeveloper
  2. Open the file ide\bin\ide.conf, scroll down to the default memory settings:
  3.         AddVMOption  -Xms128M
            AddVMOption  -Xmx768M
    
  4. Boost the memory to something larger, like so:
  5.         AddVMOption  -Xms1024M
            AddVMOption  -Xmx1024M
    
  6. Open the file jdev\bin\jdev.conf
  7. Add the following config settings:
  8.         # optimize the JVM for strings / text editing
            AddVMOption -XX:+UseStringCache
            AddVMOption -XX:+OptimizeStringConcat
            AddVMOption -XX:+UseCompressedStrings
    
            # if on a 64-bit system, but using less than 32 GB RAM, this reduces object pointer memory size
            AddVMOption -XX:+UseCompressedOops
    
            # use an aggressive garbage collector (constant small collections)
            AddVMOption -XX:+AggressiveOpts
    
            # for multi-core machines, use multiple threads to create objects and reduce pause times
            AddVMOption -XX:+UseConcMarkSweepGC
    
  9. Then restart JDeveloper... If it doesn't start, you'll need to reduce the amount of memory allocate in the ide.conf file from step 3.

ADF : Insert Row at the Top and Bottom of table

To insert row at the bottom of table follow followings steps:

Step 1 -  Generate VOimpl class of your  View Object.

Step 2 - Go to VOimpl class and add below code

         /**
     * Insert new Rows at the end of RowSet.
     * @param row
     */
    @Override
    public void insertRow(Row row) {
        //go to the end of Rowset if it has rows
        Row lastRow = this.last();
        if (lastRow !=null){
             //insert new row at the end and make it current
            int indx = this.getRangeIndexOf(lastRow)+1;
            this.insertRowAtRangeIndex(indx,row);
            this.setCurrentRow(row);
        }else { // empty Rowset
        super.insertRow(row);
        }
        }

In this way row always insert at bottom of table.


To insert row at the top of table follow following steps:

Step 1 - Generate VOimppl class of your View Object.

Step 2 -Go to VOimpl class and add below code,

         /**
     * Insert new Rows at the top of RowSet.
     * @param row
     */
    @Override
    public void insertRow(Row row) {
        //go to the First of Rowset if it has rows
        Row firstRow = this.first();
        if (firstRow !=null){
             //insert new row at the top and make it current
            int indx = this.getRangeIndexOf(firstRow);
            this.insertRowAtRangeIndex(indx,row);
            this.setCurrentRow(row);
        }else { // empty Rowset
        super.insertRow(row);
        }
        }

In this way row always insert at top of the table.


Tuesday, July 21, 2015

ADF-How To call and Execute sql function Programatically (using operationBinding.getParamsMap() )

Most of the scenarios , we need to call sql function pragmatically.

Here, is the one approch by using Map we can put input parameter to function and get result as Object.

1- Suppose we have Login Table as follows:

2-we want to fetch name of particular user id. So, for that we will create function is database as follows.

3-Now create Application Test ,create Login EO, LoginVO,
4-In AppModuleImpl.class write following method to get result from database.



5-From  Managed Bean call above method as follows:

    OperationBinding operationBinding =
                 (OperationBinding) bindings.getOperationBinding("getName");//AppModuleImpl.class method Name
operationBinding.getParamsMap().put("id", <Pass ID here>);
Object result = operationBinding.execute();//we can get Name of that user Id in result Object


ADF- How to Apply and Create View Criteria Programatically


   

 1.   I have already created a view criteria in EmployeeVO, and I want to call it programmatically.

                public void searchEmployee(Number employeeId) {
                            ViewObjectImpl vo = getEmployeesView1();    
                            ViewCriteria vc = vo.getViewCriteria("findEmployeeVC");   
                            vo.applyViewCriteria(vc);               
                            vo.setNamedWhereClauseParam("pEmployeeId", employeeId);    
                            vo.executeQuery();            
                 }


    2.    I want to create a view criteria dynamically and execute it programmatically.

                   public void searchByEmployeeIdEmail(Number employeeId, String email) {
                                   ViewObjectImpl vo = getEmployeesView2();
                                   ViewCriteria vc = vo.createViewCriteria();
                                   ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
     
                                    vcRow.setAttribute("EmployeeId", employeeId);
                                    vc.addRow(vcRow);
                                    vcRow.setAttribute("Email", email);
                                    vc.addRow(vcRow);
     
                                    vo.applyViewCriteria(vc);
                                    vo.executeQuery();
                    }