Dive into BC4J and ADF

Send me a mail
 Dive into BC4J and ADF    Click to see the XML version of this web page.   (Updated: 6/3/2006; 11:50:17 AM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper 10g

Search blog with Google:
 

Search BC4J JavaDoc:
 

December 2003
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Nov   Jan

Get Firefox!

Monday, December 01, 2003

From within your ViewObjectImpl subclass, you can evaluate the protected method:

getViewDef().isFullSql()

This will return true if the VO in question is an expert-mode view object.


4:16:47 PM    



One of my favorite features in JDeveloper 10g is the highly-streamlined "Goto Java Class" dialog. Some class name pops into your head that you want to see, you type [Ctrl]-[Minus] and start typing the name of the class (without having to remember what package it lives in) and hit [Enter] to jump quickly to the source or JavaDoc.

Today I discovered that for production, we've added a cool complementary feature called "Goto Recent Files..." which you access (in the production JDev 10g release) using the [Ctrl]-[Equals] key accelerator. It remembers the files you've most recently visited so you can quickly see them again if you happened to have closed them to clean up your workarea, but then needed to see them again for any reason. Excellent!


2:16:36 PM    


The BC4J framework combines the best of both the relational database world and the object oriented world in how it implements the collaboration between view object and entity object components. J2EE developers talk about implementing the "Fast Lane Reader" design pattern, to give flexible SQL access to your data in the fastest way possible and to allow the developer to select only the data they need. BC4J's implementation of Fast Lane Reader is coordinated with an automatic coordination with the backend business components that encapsulate and enforce the business rules. Normally, this coordination would need to be coded by hand by a J2EE not using a framework like BC4J to do something like:

  1. Possibly modified data comes back from the client in a Data Transfer Object
  2. Need to figure out which attributes in the DTO have been modified
  3. Need to find the appropriate underlying entity or entities by primary key
  4. Need to call the attribute setter methods for the modified attributes on the underlying business object to transfer the data from the model layer back into the business object layer

BC4J does this automatically as described in Section 8.1 ("Partial Object-Fetching and Middle-Tier Caching") of my first BC4J technical whitepaper on OTN. The way BC4J works, we use JDBC to query just the data you ask for in your view object's SQL query, storing that data in the underlying entity objects. This means that if you have queried only the order number and the order total for an order, only two of that Order entities attributes are populated in memory: a great savings versus fetching all attributes for all rows.

It's only when you go modify a row in the view object that we go "fault-in" the missing entity attributes using the primary key (calling your entity object's doSelect() method in the process to get the job done). We fault-in the missing attributes for modified or deleted rows so that your custom business logic can be coded assuming all attributes are always in memory.

Since in most business applications, you do a lot more reading of data than writing/changing of data, our feature to allow entities to be partially populated in memory until they are modified saves time and memory. The fault-in occurs for one of the following reasons:

  1. You have tried to setAttribute() on a existing entity object instance which is currently STATUS_UNMODIFIED.
  2. You have caused the underlying entity object to be locked in the database (if you are using optimistic locking mode, this won't happen until your post-or-commit your changes).
  3. Some business logic you have written attempts to access an attribute of the entity that is not presently populated in the entity). For example, you queried OrderId, and OrderTotal in a view object, but end up executing some business logic that calls getOrderDate() as part of its calculations.
  4. You explicitly call findByPrimaryKey() on the entity's definition object

If you are overriding the doSelect() method yourself, then the boolean flag that is passed to you by the framework indicates whether you should lock the row as well as reading its currently values in from the database.


1:48:28 PM    


© Copyright 2006 Steve Muench.