Thursday, August 25, 2011

Compiling large projects from JDeveloper

If you are running in to out of memory error while compiling huge projects from JDeveloper, this tips is for you.

JDeveloper will let you to compile the project outside of JDeveloper process where the compiler can enjoy more heap size(which doesn't need to be shared with JDeveloper). To do this select the Project, right click-> Project Properties and select Out of Process option. Optionally you can modify the default heap size as well.

Out-of-process compilations are useful for very large projects; an in-process compilation could run out of memory because it shares the memory space with the whole JDeveloper IDE.



Wednesday, August 24, 2011

What you may need to know about data types for history columns which stores date and time?

When you choose history columns data types to store 'Date', please follow the following points:

1. Always prefer java.sql.Timestamp (or similar) over java.sql.Date for history column attribute type in an entity:

Well,apart from the common benefits of using Timestamp over Date, there is one more point. The java.sql.Date will truncate the value(removing time comp) when the data is posted to data base. At this stage the database table is having truncated value and entity object has non truncated date. If the user again modifies the same row on the same date, the row consistence check may fail while posting data to database and you may get the below error

oracle.jbo.RowInconsistentException: JBO-25014: Another user has changed the row with primary key...

2. Make sure corresponding history column in database table is of type TIMESTAMP

DATE contains the datetime fields YEAR, MONTH, DAY, HOUR, MINUTE, and SECOND. TIMESTAMP stores date and time as small as the nanosecond and has the capability to track the updates happens on the same records within same second (by single/multiple users).

To learn more about history columns, please refer the following topic in Fusion Developers Guide
How to Track Created and Modified Dates Using the History Column

Sunday, August 21, 2011

Long living Dynamic Business Components

Recently I came across an interesting post from Juan Oropeza (Oracle) in an internal wiki, the code was illustrating dynamic ViewObject creation which lives beyond user sessions. Thanks to Steve Muench who did help me to understand this thing better. Today's post is on this topic.

What is so great about this concept? Well, there are few good stuff for you. Read on...

In one of my previous post, I blogged about building dynamic UI -Model driven approach for building Dynamic UI. There the life of a dynamically created view object or entity object were limited to a user session in which they were created. What if you need the dynamically created ADF business components to be available across all user, beyond a specific user session. A real life use case may be adding couple of more attributes or validations on an existing View Object definition at run time which needs be reflected across all users. Well this is quite possible by getting the personalization definition of the ViewObject - PDefViewObject and performing the alteration on it. Later, When an meta data for view object or entity definition is loaded, it checks for corresponding PDef object and, if present, superimpose the PDef on existing meta data. The end-user sees a definition that is the union of the base definition plus the additional personalizations. The below shown code snippet may help you to understand the API to be used for altering view object which needs to live beyond the user session. Please note that pDefVO.saveXMLContents() makes use of MDS to store the altered definition. To make this thing to work, you may need to have right entries added in your adf-config.xml.

 private boolean addLocAttributeToDeptView() {  
      ViewDefImpl viewDef = ViewDefImpl.findDefObject("sessiondef.dynamic.DynamicDeptViewDef");  
      PDefViewObject pDefVO = (PDefViewObject)viewDef.getPersDef();  
      if (pDefVO == null) {  
           pDefVO = new PDefViewObject();  
           pDefVO.setFullName(viewDef.getFullName());  
      }  
      if (pDefVO.getAttributeIndexOf(ATTRIB_LOC_ID) != -1) {  
           return false;  
      }  
      pDefVO.setEditable(true);  
      pDefVO.addEntityAttribute(ATTRIB_LOC_ID, "DynamicDeptUsage", ATTRIB_LOC_ID, true);  
      pDefVO.applyPersonalization(findViewObject(DYNAMIC_DETP_VO_INSTANCE));  
      pDefVO.writeXMLContents();  
      pDefVO.saveXMLContents();  
      return true;  
 }  

Download

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11.1.2.0.0 (11g R2) + HR Schema]

A glance at the implementation

This example uses personalizedbc-sample-task-flow-definition to create a dynamic entity object and view Object. The second step in the task flow alter the dynamic view object to add location id right before displaying the dynamically created VO to end user.


The adf-config.xml used for this example has been configured to use file based MDS store to keep the dynamic business component definitions.
 <persistence-config>  
      <metadata-namespaces>  
           <namespace path="/sessiondef" metadata-store-usage="mdsRepos"/>  
           <namespace path="/persdef" metadata-store-usage="mdsRepos"/>  
           <namespace path="/xliffBundles" metadata-store-usage="mdsRepos"/>  
      </metadata-namespaces>  
      <metadata-store-usages>  
           <metadata-store-usage id="mdsRepos" deploy-target="true" default-cust-store="true"/>  
           <!-- <property name="metadata-path" value="/tmp"/> -->  
      </metadata-store-usages>  
 </persistence-config>  

How to run this sample?

1. Run main.jspx
2. This sample is security enabled. Key in user name/password as developer1/developer1, when asked for.
3. The above mentioned task flow generates DynamicDeptEntityDef and DynamicDeptViewDef at runtime and saves the definition to MDS store. The DynamicDeptVO1 is exposed to client for use.
4. Run the main.jsf once again and this time enter username/password as developer2/developer2. You may notice that previously created VO definition is available to the second user as well.


Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post- http://jobinesh.blogspot.in/2012/07/pre-order-your-copy-of-oracle-adf-real.html





Wednesday, August 17, 2011

What you may need to know about useBindVarsForViewCriteriaLiterals in adf-config.xml?

The 11.1.2 release has introduced a new flag useBindVarsForViewCriteriaLiterals in your application's adf-config.xml.
 <?xml version="1.0" encoding="US-ASCII" ?>  
 <adf-config .... >  
   <adf-adfm-config xmlns="http://xmlns.oracle.com/adfm/config">  
   <defaults useBindVarsForViewCriteriaLiterals="true"/>  
   ...  
  </adf-adfm-config>  
   ...  

Idea is to force the run time to generate temporary bind variables instead of directly using literal values while generating WHERE clause for the ViewCriteria. The above said configuration is done at application level which will set ViewCriteria::setUseBindVarsForLiterals(true) for all VC instances.
  • This will help to improve performance of query execution by caching SQLs
  • Reduce/avoid the chance for SQL injection