Wednesday, October 3, 2012
ADF Custom SQL Builders
ADF allows us to create and configure custom SQL builders. Since ADF’s SQL builders don’t support all the SQL Flavors, there might be a need to create your own SQL Builder and configure it.
1. Create a SQL Builder Class.
You can create a custom builder class by extending one of the following classes
oracle.jbo.server.SQL92SQLBuilderImpl
oracle.jbo.server.BaseSQLBuilderImpl
or to extend current functionality of existing builders you can also extend
oracle.jbo.server.SQLServerSQLBuilderImpl
oracle.jbo.server.DB2SQLBuilderImpl
oracle.jbo.server.OracleSQLBuilderImpl
Below is a simple example to override query to get time from the database
package a.b.c.extn;
import oracle.jbo.server.SQLBuilder;
import oracle.jbo.server.SQL92SQLBuilderImpl;
public class MySQLBuilder extends SQL92SQLBuilderImpl
{
public MySQLBuilder () {
super();
}
public static SQLBuilder getInterface()
{
return new MySQLBuilder ();
}
/* (non-Javadoc)
* @see oracle.jbo.server.BaseSQLBuilderImpl#getDbTimeQuery()
*/
public String getDbTimeQuery()
{
return "select getdate()";
}
}
2. Configuring the Custom SQL builder in the application
In the adf-config.xml, go to Business Components Tab.
Change the SQL Flavor to Custom and in the SQL Builder Class, give the class name as shown below
<adf-adfm-config xmlns="http://xmlns.oracle.com/adfm/config">
<defaults/>
<startup>
<amconfig-overrides>
<config:Database jbo.SQLBuilder="Custom"
jbo.SQLBuilderClass="a.b.c.extn.MySQLBuilder" jbo.locking.mode="optimistic"/>
</amconfig-overrides>
</startup>
Subscribe to:
Post Comments (Atom)
I really like your article. It’s evident that you have a lot knowledge on this topic. Your points are well made and relatable. Thanks for writing engaging and interesting material. estimation
ReplyDelete