Dynamically changing query in view object in Oracle ADF

I have also written in my past post that how can you change the query my old post to change query . Here is another way.

Sometime requirements can be dynamically change SQL query where clause in View Object. I found on internet .so for the reference, i am sharing.

To use this functionality, you need to override buildWhereClause(StringBuffer sqlBuffer, int noBindVars) method in view object implementation. You use sqlBuffer parameter in this method (which contains SQL query where in StringBuffer) to change SQL in correlation to you needs. Just replace, remove, add string in this parameter. Just remember to use same bind variables names which will be use in VO SQL call (generic bind variables names are named like :vc_temp_1, :vc_temp_2,…).

    @Override  
        protected boolean buildWhereClause(StringBuffer sqlBuffer, int noBindVars) {  
      
            //call super and see if there is where clause.  
            boolean hasWhereClause = super.buildWhereClause(sqlBuffer, noBindVars);  
      
            if (hasWhereClause) {   
                //modify existing where query.  
            }  
            else {   
                //or if you add where clause then return true;  
                hasWhereClause = false;   
      
            }  
      
            return hasWhereClause;  
        }  


Vinay

I am an Oracle ACE in Oracle ADF/Webcenter. Sr Java Consultant-working on Java/J2EE/Oracle ADF/Webcenter Portal/ content and Hibernate for several years. I'm an active member of the OTN JDeveloper/Webcenter forum. Passionate about learning new technologies. I am here to share my knowledge. Give your views and suggestion on [email protected] .

More Posts - Website

Follow Me:
TwitterLinkedInGoogle PlusYouTube