SlideShare a Scribd company logo
ADF Developers – make the database work for youODTUG Kaleidoscope 2011 – Long Beach, CaliforniaLuc Bors, AMIS, The Netherlands
DesktopBrowser-BasedMetadata Services (MDS)Oracle ADF – Role of the DatabaseJSFJSPOfficeADFSwingMobileViewADF Faces      JSFStrutsADF ControllerControllerADF BindingModelBusiness ServicesEJBBAMADFbcPortletsBIBPELWeb ServicesJavaData ServicesDatabaseWeb ServicesLegacy SystemsApps Unlimited
“We could also do that in the database”in the database? Huh?RDBMS≈
Design & team that combines strengths of all technologies…Ease and Elegance of Implementation
Functionality (in an affordable way)
Productivity
PerformanceADF Controller/ADF FacesADF ModelADF BC/JPA/WS*Oracle RDBMS
Database StrengthsIntegrityFine grained (data) security and auditingData Retrieval joining tables together, leveraging indexeshierarchical, network-like traversals advanced analytics, historical queries, mining Aggregation and SortingComplex & Massive Data Manipulation
RDBMS not always exclusively accessed through one Java APISOA, ESB, WebServicesDatabaseBatch Bulk ProcessesStandard ApplicationsLegacyApplicationsData Replication & Synchronization
Database Triggers – decorating Data ManipulationTriggers execute before or after Insert, Update or Delete of database recordsinsert, update, deleteBefore Insert trigger: sal=…Employees
Purpose of triggersSet default values on new recordsif :new.job=‘SALESMAN’ then :new.comm = 1000Calculate & Derive values upon insert, update or deleteNotify third parties of data manipulationPerform complex validation on the data changes applied by the transactionPer Department: Max Salary < 1.8 * AveragePer Manager: #subordinates < 15
ADF BC refreshing Entity Objects after triggers have applied new valuesEntity Object Employee(leveraging: returning <column> into : bind)postBefore Insert trigger: sal=…Employees
Aggregation & RollupData for reporting purposes can be prepared by database queriesIncluding aggregations(max/min/avg/count/sum)and Sub Totals and Grand Totaland String Aggregation
Dynamic Aggregation through Non-conventional use of bind parametersBind parameters are typically used in the WHERE clause of a SQL queryHowever: they can also be used in the SELECT, ORDER BY and GROUP BY sectionsA combination of CASE and bind parameters in the GROUP BY can provide interesting optionsDynamicAggregation
Query for dynamic aggregation
Sub and Grandtotals with RollupRollup instructs databaseto aggregate at every levelstarting from the rightdeptno, jobdeptno(grand total)Also see:CubeGroupingSets
Leveraging SQL Aggregation to make life easier for the UI developer
Analytical Functions – spreadsheet-style row processingAnalytical Functions allow SQL queries to perform inter-row comparison & aggregationFor example: in a single query, for each employeeshow salary rank in department and jobshow salary difference with colleague next higher in rank (on the list per department)show average salary in the departmentshow csv list of colleagues in department
Analytical Functions - example
Flashback Queryselect emp.*,      dept.dnamefrom   emp AS OF TIMESTAMP                  (SYSTIMESTAMP - INTERVAL '1' DAY) ,      deptwhere  emp.deptno = dept.deptno
Show historic situation for selected records
Flashback VersionsRetrieve all states each record has been inEvery transaction that touched a row left a version of the recordPseudocolumns: xid, operation, start time, end timeUse constants minvalueand maxvalueto retrieve all versionsFlashback versions make journaling tables redundant
Employee Version-history with Flashback Query
Show change history for a record based on Flashback versions
Embedding Historic Data in ADF ApplicationWhere Clause in (read only) ViewObject can include FLASHBACK operatorsAS OF and VERSIONS BETWEENBind parameters can be used to set the point in time or the historic time intervalA time selector can be used to visually set the intervalScalar subqueries can be used for ‘in line comparison to a certain point in time’“How much higher/lower is the salary than at the selected date?”
Trees
Trees
ADF Model & Tree Data BindingCreate hierarchical relation between multiple ViewObject or (POJO) Collection BindingsTree Data Retrieval retrieves collections in several steps i.e. multiple queriesData is cachedData is only queried when required (given the expansion level of the tree)Alternatively: have the database do the heavy tree lifting: Database has optimized tree algorithmsStarting at any node in the tree or networkDrilling down to the specified number of levelsOrder siblings within parentIndicate leaf and parent nodes; detect cycles
Retrieving Hierarchical data sets with single SQL statementsDatabase has optimized algorithmsStarting at any node in the tree or networkDrilling down to the specified number of levelsOrder siblings within parentIndicate leaf and parent nodes; detect cyclesEMPID           ENAME             MGR     DEPTNO      LEVEL--------------- ---------- ---------- ---------- ----------  7839          KING                          10          1    7698        BLAKE            7839         30          2      7499      ALLEN            7698         30          3      7900      JAMES            7698         30          3      7654      MARTIN           7698         30          3      7844      TURNER           7698         30          3      7521      WARD             7698         30          3    7782        CLARK            7839         10          2      7934      MILLER           7782         10          3
Oracle 11g and ANSI SQL for hierarchical querywith employees (empno, name, mgr, hierlevel, path) as ( select empno, ename, mgr, 1, ename  from   emp  where  mgr is null  union all  select e.empno, e.ename  ,      e.mgr, m.hierlevel + 1  ,      m.path||'/'||e.ename  from   emp e         join         employees m         on (m.empno = e.mgr) )select *from   employees
Filter-driven queryingFilteredEmp
Steps for filter driven queryingDetermine the values to filter onCreate a query to retrieve for all filtersEvery individual value and the # occurrencesThe where-clause to apply on the real VOThe label for the filterCreate a managed bean to apply selected filtersto ViewObjectCreate page that displays filters and selected dataand handles filter “clicks”
Encapsulate Database specific SQL in a View APIViews – for encapsulation of data model, multi-table join, (advanced) SQL hiding, authorization rulesNote: a view looks like a table to the clientView
The read-only cursor APIA Cursor is a  reference to a query result setDatabase can open a cursor for a SQL queryAnd return it to the application to fetch the rows fromCursor == JDBCResultSetA cursor can be nested: containdetails … JDBC ResultSetwhile rs.next {   … }cursorStored ProcedureDepartmentsSQLEmployees
Cursor for Master-Detail resultsetStored Procedure
Using Complex Views for Hiding Legacy Data Models
Providing a ‘business object’ APIDML API: a View – aided by an Instead Of triggerInsert of one new row inUSERS_VW (e.g. a JPApersist operation) can actually be four new recordsUSER, PERSON, EMAIL_TYPEEMAIL_ADDRESSUSERSUSERSEMAIL_TYPEInstead Of DML trigger**PERSONSEMAIL_ADDRESSES**
Instead of Insert Trigger on USERS_VW (1/2)create or replace trigger handle_insert_users_trginstead of insert on users_vwfor each row declare  l_psn_id persons.id%type;begin insert into persons ( id, first_name, last_name, address, ...)  values  ( nvl(:new.id, central_seq.nextval),:new.first_name   , :new.last_name, :new.address, ...)  returning id into l_psn_id;  insert into user_accounts  ( id, psn_id, username, password)  values  ( central_seq.nextval ,l_psn_id , :new.username   , :new.password);
Instead of Insert Trigger on USERS_VW (2/2)...   insert into email_addresses  ( id, psn_id, ete_id, address)  values  ( central_seq.nextval  , l_psn_id  , ( select id       from   email_types ete       where  ete.address_type = :new.primary_email_type    )  , :new.primary_email)  ;end handle_insert_users_trg;
Creating a new userUser AdministrationUSERSFirst NameLast NameMollyWarholUsernamePasswordmwarhol******USERSEMAIL_TYPEInstead Of DML triggerAddressCity1 SlickroadLas VegasTelephoneMobile555121243219876*EmailEmail typemw@un.orgBusinessPERSONSEMAIL_ADDRESSESActivation24-may-2008**
ADF BC and Complex Views with Instead of TriggersOverride the lock method in the ViewObjectImplDefault implementation will attempt select … from <view> for update ofWhich is not allowed on Views with an instead of trigger
Do not do it…More often than requiredSave on network trips, context switches and tiers to crossSave on ‘reproducing’ same resultsWeb BrowserJS data (memory)
Cookies
 HTML 5 dbEdge CacheJEE Application ServerCacheCluster Fail-Over(Session State)Result StoreWrite BehindClient Result CacheRDBMSResult CacheMaterialized View
The Hollywood Principle: Query ResultSet Change NotificationPOJO / ADF BC
Cache Refresh triggered by DBOracle RDBMS invokes Java Listener with event detailsPOJO / ADF BCRegister DatabaseChangeNotificationSQL queryPL/SQL
Shared Application ModulesNormal Application Module instances are session level – i.e. not shared across (web) sessionsShared Application Module instances are shared across sessions like an Application Scope Managed BeanUsed for Static Data Sets: Look Up Data and Reference TablesSessions can reuse the data from a shared Application Module without having to access the databaseAnd loading the same data in session level memory scopeView Accessors can be used to access data in the Shared Application Module’s VOsFor example for use in LOVs or Validation Rules
Shared Application Module Instance
Auto Refresh for ViewObjectsViewObjects in a Shared Application Module can be registered for auto refreshTypically such application wide VOs are near-staticWhenever the underlying data set changes (in the database), the VO rowset should be refreshedBy setting Auto Refresh (to true) for the ViewObject, the VO will be refreshed whenever the database is changedADF registers the VO query with the Database (11g) Result Set Change Notification mechanism through JDBCNote: the VO should not have an Order By clause nor select a Date column
Steps for auto refresh enablingCreate Shared Application ModuleNew application module that is added to list of Application Level instances in the Project propertiesCreate the ViewObject that queries the ‘static data’ and add to Shared Application ModuleSet the Auto Refresh property to true for VO instanceDatabase must be 11g (and have parameter compatible set to 11.1.0 or above)database user must have the Change Notification privilegeTo piggyback changes to page, set changeEventPolicy to autoPPR on data binding
Set Auto Refresh for ViewObjectSet Auto Refresh for ViewObjectGrant Change Notification todatabase user

More Related Content

PPTX
Introduce to Spark sql 1.3.0
PDF
Introduction to Spark SQL & Catalyst
PPTX
Ten tools for ten big data areas 04_Apache Hive
PPTX
Honey I Shrunk the Database
PPT
OWB11gR2 - Extending ETL
PDF
Advanced MySQL Query Optimizations
PPTX
Machine learning using spark
PDF
TSQL Coding Guidelines
Introduce to Spark sql 1.3.0
Introduction to Spark SQL & Catalyst
Ten tools for ten big data areas 04_Apache Hive
Honey I Shrunk the Database
OWB11gR2 - Extending ETL
Advanced MySQL Query Optimizations
Machine learning using spark
TSQL Coding Guidelines

What's hot (18)

PPTX
Example R usage for oracle DBA UKOUG 2013
PPTX
U-SQL Query Execution and Performance Tuning
PPT
Drill / SQL / Optiq
PDF
SQL to Hive Cheat Sheet
PDF
Don't optimize my queries, organize my data!
PPT
Hive User Meeting August 2009 Facebook
PPT
MySQL lecture
PPSX
MS SQL Server
PDF
ORACLE BY KMR SOFTWARE SERVICES
ODP
Ms sql-server
PDF
Don’t optimize my queries, optimize my data!
PPT
9780538745840 ppt ch06
PDF
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
PPT
Sql views
PPT
Sql Summit Clr, Service Broker And Xml
PPT
MySql slides (ppt)
PPT
PPTX
Orcale dba training
Example R usage for oracle DBA UKOUG 2013
U-SQL Query Execution and Performance Tuning
Drill / SQL / Optiq
SQL to Hive Cheat Sheet
Don't optimize my queries, organize my data!
Hive User Meeting August 2009 Facebook
MySQL lecture
MS SQL Server
ORACLE BY KMR SOFTWARE SERVICES
Ms sql-server
Don’t optimize my queries, optimize my data!
9780538745840 ppt ch06
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
Sql views
Sql Summit Clr, Service Broker And Xml
MySql slides (ppt)
Orcale dba training
Ad

Similar to Odtug2011 adf developers make the database work for you (20)

PPTX
Web Developer make the most out of your Database !
PDF
ILOUG 2019 - SQL features for Developers
PPT
2 sql - single-row functions
PPT
Pl sql guide
PPTX
Absolutely Typical - The whole story on Types and how they power PL/SQL Inter...
DOCX
Oracle 11g developer on linux training in bangalore
DOCX
Oracle 11g developer on linux training in bangalore
DOCX
Java full stack1
PDF
Database Oracle Basic
PDF
UKOUG 2019 - SQL features
PPT
Java Developers, make the database work for you (NLJUG JFall 2010)
PDF
DBMS Lab
PDF
Connor McDonald 11g for developers
PPTX
OpenWorld Sep14 12c for_developers
PPTX
Developer's Approach to Code Management
DOC
SQLQueries
PPT
PPT
MDI Training DB2 Course
PDF
Sql wksht-5
PDF
OOW19 - Ten Amazing SQL features
Web Developer make the most out of your Database !
ILOUG 2019 - SQL features for Developers
2 sql - single-row functions
Pl sql guide
Absolutely Typical - The whole story on Types and how they power PL/SQL Inter...
Oracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangalore
Java full stack1
Database Oracle Basic
UKOUG 2019 - SQL features
Java Developers, make the database work for you (NLJUG JFall 2010)
DBMS Lab
Connor McDonald 11g for developers
OpenWorld Sep14 12c for_developers
Developer's Approach to Code Management
SQLQueries
MDI Training DB2 Course
Sql wksht-5
OOW19 - Ten Amazing SQL features
Ad

More from Luc Bors (20)

PDF
Talk to me Goose: Going beyond your regular Chatbot
PDF
Extending Oracle SaaS Using Oracle Cloud UX Rapid Development Kit
PDF
NO CODE : Or How to Extend Oracle SaaS with Oracle Visual Builder Cloud Service
PDF
Real Life MAF (2.2) Oracle Open World 2015
PDF
Real life-maf-2015-k scope-final
PPTX
Real life-maf-2015
PDF
ADF Essentials (KScope14)
PDF
Reaching out from ADF Mobile (ODTUG KScope 2014)
PDF
OgH Data Visualization Special Part III
PDF
OgH Data Visualization Special Part II
PDF
OgH Data Visualization Special Part I
PDF
MAF push notifications
PDF
Doag wysiwyg
PDF
amis-adf-enterprise-mobility
PDF
Oracle day 2014-mobile-customer-case
PDF
Oracle MAF real life OOW.pptx
PDF
AMIS UX Event 2014: Mobile ADF; From Design To Device; The Tools that make it...
PDF
ADF Mobile: 10 Things you don't get from the developers guide
PPTX
oow2013-adf-mo-bi-le
PDF
Goodbye Nightmare : Tops and Tricks for creating Layouts
Talk to me Goose: Going beyond your regular Chatbot
Extending Oracle SaaS Using Oracle Cloud UX Rapid Development Kit
NO CODE : Or How to Extend Oracle SaaS with Oracle Visual Builder Cloud Service
Real Life MAF (2.2) Oracle Open World 2015
Real life-maf-2015-k scope-final
Real life-maf-2015
ADF Essentials (KScope14)
Reaching out from ADF Mobile (ODTUG KScope 2014)
OgH Data Visualization Special Part III
OgH Data Visualization Special Part II
OgH Data Visualization Special Part I
MAF push notifications
Doag wysiwyg
amis-adf-enterprise-mobility
Oracle day 2014-mobile-customer-case
Oracle MAF real life OOW.pptx
AMIS UX Event 2014: Mobile ADF; From Design To Device; The Tools that make it...
ADF Mobile: 10 Things you don't get from the developers guide
oow2013-adf-mo-bi-le
Goodbye Nightmare : Tops and Tricks for creating Layouts

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Approach and Philosophy of On baking technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Big Data Technologies - Introduction.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
KodekX | Application Modernization Development
PDF
Modernizing your data center with Dell and AMD
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Cloud computing and distributed systems.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
A Presentation on Artificial Intelligence
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Unlocking AI with Model Context Protocol (MCP)
Approach and Philosophy of On baking technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Big Data Technologies - Introduction.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
KodekX | Application Modernization Development
Modernizing your data center with Dell and AMD
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectral efficient network and resource selection model in 5G networks
Cloud computing and distributed systems.
The AUB Centre for AI in Media Proposal.docx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
NewMind AI Monthly Chronicles - July 2025
A Presentation on Artificial Intelligence
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”

Odtug2011 adf developers make the database work for you

  • 1. ADF Developers – make the database work for youODTUG Kaleidoscope 2011 – Long Beach, CaliforniaLuc Bors, AMIS, The Netherlands
  • 2. DesktopBrowser-BasedMetadata Services (MDS)Oracle ADF – Role of the DatabaseJSFJSPOfficeADFSwingMobileViewADF Faces JSFStrutsADF ControllerControllerADF BindingModelBusiness ServicesEJBBAMADFbcPortletsBIBPELWeb ServicesJavaData ServicesDatabaseWeb ServicesLegacy SystemsApps Unlimited
  • 3. “We could also do that in the database”in the database? Huh?RDBMS≈
  • 4. Design & team that combines strengths of all technologies…Ease and Elegance of Implementation
  • 5. Functionality (in an affordable way)
  • 7. PerformanceADF Controller/ADF FacesADF ModelADF BC/JPA/WS*Oracle RDBMS
  • 8. Database StrengthsIntegrityFine grained (data) security and auditingData Retrieval joining tables together, leveraging indexeshierarchical, network-like traversals advanced analytics, historical queries, mining Aggregation and SortingComplex & Massive Data Manipulation
  • 9. RDBMS not always exclusively accessed through one Java APISOA, ESB, WebServicesDatabaseBatch Bulk ProcessesStandard ApplicationsLegacyApplicationsData Replication & Synchronization
  • 10. Database Triggers – decorating Data ManipulationTriggers execute before or after Insert, Update or Delete of database recordsinsert, update, deleteBefore Insert trigger: sal=…Employees
  • 11. Purpose of triggersSet default values on new recordsif :new.job=‘SALESMAN’ then :new.comm = 1000Calculate & Derive values upon insert, update or deleteNotify third parties of data manipulationPerform complex validation on the data changes applied by the transactionPer Department: Max Salary < 1.8 * AveragePer Manager: #subordinates < 15
  • 12. ADF BC refreshing Entity Objects after triggers have applied new valuesEntity Object Employee(leveraging: returning <column> into : bind)postBefore Insert trigger: sal=…Employees
  • 13. Aggregation & RollupData for reporting purposes can be prepared by database queriesIncluding aggregations(max/min/avg/count/sum)and Sub Totals and Grand Totaland String Aggregation
  • 14. Dynamic Aggregation through Non-conventional use of bind parametersBind parameters are typically used in the WHERE clause of a SQL queryHowever: they can also be used in the SELECT, ORDER BY and GROUP BY sectionsA combination of CASE and bind parameters in the GROUP BY can provide interesting optionsDynamicAggregation
  • 15. Query for dynamic aggregation
  • 16. Sub and Grandtotals with RollupRollup instructs databaseto aggregate at every levelstarting from the rightdeptno, jobdeptno(grand total)Also see:CubeGroupingSets
  • 17. Leveraging SQL Aggregation to make life easier for the UI developer
  • 18. Analytical Functions – spreadsheet-style row processingAnalytical Functions allow SQL queries to perform inter-row comparison & aggregationFor example: in a single query, for each employeeshow salary rank in department and jobshow salary difference with colleague next higher in rank (on the list per department)show average salary in the departmentshow csv list of colleagues in department
  • 20. Flashback Queryselect emp.*, dept.dnamefrom emp AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' DAY) , deptwhere emp.deptno = dept.deptno
  • 21. Show historic situation for selected records
  • 22. Flashback VersionsRetrieve all states each record has been inEvery transaction that touched a row left a version of the recordPseudocolumns: xid, operation, start time, end timeUse constants minvalueand maxvalueto retrieve all versionsFlashback versions make journaling tables redundant
  • 24. Show change history for a record based on Flashback versions
  • 25. Embedding Historic Data in ADF ApplicationWhere Clause in (read only) ViewObject can include FLASHBACK operatorsAS OF and VERSIONS BETWEENBind parameters can be used to set the point in time or the historic time intervalA time selector can be used to visually set the intervalScalar subqueries can be used for ‘in line comparison to a certain point in time’“How much higher/lower is the salary than at the selected date?”
  • 26. Trees
  • 27. Trees
  • 28. ADF Model & Tree Data BindingCreate hierarchical relation between multiple ViewObject or (POJO) Collection BindingsTree Data Retrieval retrieves collections in several steps i.e. multiple queriesData is cachedData is only queried when required (given the expansion level of the tree)Alternatively: have the database do the heavy tree lifting: Database has optimized tree algorithmsStarting at any node in the tree or networkDrilling down to the specified number of levelsOrder siblings within parentIndicate leaf and parent nodes; detect cycles
  • 29. Retrieving Hierarchical data sets with single SQL statementsDatabase has optimized algorithmsStarting at any node in the tree or networkDrilling down to the specified number of levelsOrder siblings within parentIndicate leaf and parent nodes; detect cyclesEMPID ENAME MGR DEPTNO LEVEL--------------- ---------- ---------- ---------- ---------- 7839 KING 10 1 7698 BLAKE 7839 30 2 7499 ALLEN 7698 30 3 7900 JAMES 7698 30 3 7654 MARTIN 7698 30 3 7844 TURNER 7698 30 3 7521 WARD 7698 30 3 7782 CLARK 7839 10 2 7934 MILLER 7782 10 3
  • 30. Oracle 11g and ANSI SQL for hierarchical querywith employees (empno, name, mgr, hierlevel, path) as ( select empno, ename, mgr, 1, ename from emp where mgr is null union all select e.empno, e.ename , e.mgr, m.hierlevel + 1 , m.path||'/'||e.ename from emp e join employees m on (m.empno = e.mgr) )select *from employees
  • 32. Steps for filter driven queryingDetermine the values to filter onCreate a query to retrieve for all filtersEvery individual value and the # occurrencesThe where-clause to apply on the real VOThe label for the filterCreate a managed bean to apply selected filtersto ViewObjectCreate page that displays filters and selected dataand handles filter “clicks”
  • 33. Encapsulate Database specific SQL in a View APIViews – for encapsulation of data model, multi-table join, (advanced) SQL hiding, authorization rulesNote: a view looks like a table to the clientView
  • 34. The read-only cursor APIA Cursor is a reference to a query result setDatabase can open a cursor for a SQL queryAnd return it to the application to fetch the rows fromCursor == JDBCResultSetA cursor can be nested: containdetails … JDBC ResultSetwhile rs.next { … }cursorStored ProcedureDepartmentsSQLEmployees
  • 35. Cursor for Master-Detail resultsetStored Procedure
  • 36. Using Complex Views for Hiding Legacy Data Models
  • 37. Providing a ‘business object’ APIDML API: a View – aided by an Instead Of triggerInsert of one new row inUSERS_VW (e.g. a JPApersist operation) can actually be four new recordsUSER, PERSON, EMAIL_TYPEEMAIL_ADDRESSUSERSUSERSEMAIL_TYPEInstead Of DML trigger**PERSONSEMAIL_ADDRESSES**
  • 38. Instead of Insert Trigger on USERS_VW (1/2)create or replace trigger handle_insert_users_trginstead of insert on users_vwfor each row declare l_psn_id persons.id%type;begin insert into persons ( id, first_name, last_name, address, ...) values ( nvl(:new.id, central_seq.nextval),:new.first_name , :new.last_name, :new.address, ...) returning id into l_psn_id; insert into user_accounts ( id, psn_id, username, password) values ( central_seq.nextval ,l_psn_id , :new.username , :new.password);
  • 39. Instead of Insert Trigger on USERS_VW (2/2)... insert into email_addresses ( id, psn_id, ete_id, address) values ( central_seq.nextval , l_psn_id , ( select id from email_types ete where ete.address_type = :new.primary_email_type ) , :new.primary_email) ;end handle_insert_users_trg;
  • 40. Creating a new userUser AdministrationUSERSFirst NameLast NameMollyWarholUsernamePasswordmwarhol******USERSEMAIL_TYPEInstead Of DML triggerAddressCity1 SlickroadLas VegasTelephoneMobile555121243219876*EmailEmail typemw@un.orgBusinessPERSONSEMAIL_ADDRESSESActivation24-may-2008**
  • 41. ADF BC and Complex Views with Instead of TriggersOverride the lock method in the ViewObjectImplDefault implementation will attempt select … from <view> for update ofWhich is not allowed on Views with an instead of trigger
  • 42. Do not do it…More often than requiredSave on network trips, context switches and tiers to crossSave on ‘reproducing’ same resultsWeb BrowserJS data (memory)
  • 44. HTML 5 dbEdge CacheJEE Application ServerCacheCluster Fail-Over(Session State)Result StoreWrite BehindClient Result CacheRDBMSResult CacheMaterialized View
  • 45. The Hollywood Principle: Query ResultSet Change NotificationPOJO / ADF BC
  • 46. Cache Refresh triggered by DBOracle RDBMS invokes Java Listener with event detailsPOJO / ADF BCRegister DatabaseChangeNotificationSQL queryPL/SQL
  • 47. Shared Application ModulesNormal Application Module instances are session level – i.e. not shared across (web) sessionsShared Application Module instances are shared across sessions like an Application Scope Managed BeanUsed for Static Data Sets: Look Up Data and Reference TablesSessions can reuse the data from a shared Application Module without having to access the databaseAnd loading the same data in session level memory scopeView Accessors can be used to access data in the Shared Application Module’s VOsFor example for use in LOVs or Validation Rules
  • 49. Auto Refresh for ViewObjectsViewObjects in a Shared Application Module can be registered for auto refreshTypically such application wide VOs are near-staticWhenever the underlying data set changes (in the database), the VO rowset should be refreshedBy setting Auto Refresh (to true) for the ViewObject, the VO will be refreshed whenever the database is changedADF registers the VO query with the Database (11g) Result Set Change Notification mechanism through JDBCNote: the VO should not have an Order By clause nor select a Date column
  • 50. Steps for auto refresh enablingCreate Shared Application ModuleNew application module that is added to list of Application Level instances in the Project propertiesCreate the ViewObject that queries the ‘static data’ and add to Shared Application ModuleSet the Auto Refresh property to true for VO instanceDatabase must be 11g (and have parameter compatible set to 11.1.0 or above)database user must have the Change Notification privilegeTo piggyback changes to page, set changeEventPolicy to autoPPR on data binding
  • 51. Set Auto Refresh for ViewObjectSet Auto Refresh for ViewObjectGrant Change Notification todatabase user
  • 53. Reaching out from the databaseDatabase
  • 55. Database receiving and sending emails – from people or applications
  • 58. JEE Application ServerEnterprise Service BusADF ApplicationWeb Service?Database informing and leveraging the middle tierHTTP calls using the UTL_HTTP package
  • 59. Asynchronous processingExecute stored procedures or command scripts (O/S) in the background – using a jobFree up the synchronous threadReturn control to invoking Java applicationIdeal for Fire-and-Forget (one way) callsResults can be returned asynchronouslyVia Queue, Table, Database Query Result Change Notification, HTTP call, Email,…Create a Job in the Oracle Database using:package dbms_scheduler
  • 60. Other Database Features worth investigating Virtual Private Database & Fine Grained AuthorizationXMLType, XMLDB & FTP/HTTP/WEBDAV serverObject Types and CollectionsData type Interval & Time Zone supportFine Grained AuditingSystem Triggers, for example “after logon”(Global) Application ContextAutonomous TransactionAdvanced Queuing (& JMS interaction)Creating advanced job execution schedulesEdition Based Redefinition (versioning of database objects)Statistics and Data MiningScalar Subqueries
  • 61. Summary & ConclusionsDatabases can do much more thanADF applications can benefit!Strike the right balance:Leverage database forwhat it can do bestMake ADF and Database work together in a smooth way

Editor's Notes

  • #2: Process
  • #12: http://technology.amis.nl/blog/4162/dynamic-and-conditional-grouping-in-sql-queries-for-flexible-results-from-single-query-oh-and-a-useful-case-for-the-cube-operator
  • #15: http://technology.amis.nl/blog/4191/adf-11g-treetable-with-sub-totals-how-the-sql-query-can-make-life-easier-for-the-view-developer
  • #17: select ename, sal, deptno, job, rank() over (partition by deptno order by saldesc) sal_rank_in_dept, rank() over (partition by job order by saldesc) sal_rank_in_job, lag(sal,1) over (partition by deptno order by saldesc) diff_with_next_higher_in_dept, listagg(ename, &apos;,&apos;) within group (order by ename) over (partition by deptno) colleaguesfrom emporderby deptno, saldesc
  • #23: http://technology.amis.nl/blog/3255/integrating-flashback-in-adf-web-applications-providing-the-historic-perspectivehttp://technology.amis.nl/documents/technology/dvt.pdf
  • #40: Cache – spreekuit: kasjeKastjesBrowser: Client (browser, cookie or Java Script memory; HTML 5 offers persistent, cross session local db like storage)App Server : Edge (WebServer)JVM (and cluster)Cross cluster shared cachedb or memory gridDatabase (not requery at least)
  • #51: Screenshot:Frank sends email to Maggie – with a query on EmployeesAfter some time, a response is sent to this particular email – by the queue listener using the JSP to send(list of employee data, corresponding with “query”)