Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:12:41 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

March 2004
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      
Feb   Apr

Get Firefox!

Monday, March 29, 2004

Are you one of those kinds of people, like me, who love to share what technical tidbits you learn during the day with as many people as you can reach?  Are you already keeping a weblog somewhere and have forgotten (or just didn't think) to email me to tell me about it, by chance? If not, have you ever thought of starting a weblog yourself, even if you might only have time to post once and a while? Hosted blogging sites like http://radio.userland.com, http://www.typepad.com/, and http://www.blogger.com (among probably several others) make it easy to get started. If you do have a blog, or do start one and you make technical postings that might be of interest to Java developers working with Oracle technologies, drop me (steve.muench@oracle.com) or brian.duff@oracle.com a mail about your Oracle-related blog and we'll be sure to check it out.

9:18:51 PM    



Today I was looking into an issue with view links to help out my buddy Clemens with a problem he was facing at a customer site on Friday.

As I was looking into it, I had the strange feeling that I'd looked into this issue before. However, I recalled not being able to isolate the root of the problem the previous time I investigated similar symptoms a few months back for a Dutch software house building a large application with BC4J. This time I got to the bottom of it.

The symptoms were as follows (stated in terms of Dept and Emp to keep things easier to follow):

  • In the application, a primary key column in their DEPT table had a name with an underscore like DEPT_NO.
  • While trying to create a view link between DeptView and EmpView, on the "View Link SQL" panel of the view link editor, the "Where" clause was showing up as:

    :1 = DEPTNO

    when the developer was expecting to see DEPT_NO with an underscore.
  • Because the developer noticed that "BC4J had made an error" in putting the name of the underlying DEPT_NO column, he corrected it by hand to read:

    :1 = DEPT_NO

    otherwise it was generating a runtime SQL error because the view-link WHERE clause without the underscore in the DEPT_NO column name was not matching the name of the column in the table.

The corollary of having to hand-edit the view link WHERE clause was that BC4J considers that view-link to be "expert-mode" in the sense that, by design, the developer can introduce an arbitrarily complicated SQL where clause fragment there to get the view link to be exactly what is needed by the application.

When a view-link contains a developer-modified Where clause, then there are at least two other side-effects:

  1. View link consistency is automatically disabled on the target (detail) view object at runtime, because to enforce it properly would require that BC4J have the ability to evaluate in-memory an arbitrarily-complex SQL where clause fragment to decide whether or not a new detail row would qualify for being in that detail rowset or not.
  2. The view link cannot be bidirectional at runtime, meaning that while a view link accessor is exposed for a parent (DeptView) row to access its collection of detail (EmpView) rows, the reverse accessor is not available for traversing from an EmpView row back to a collection of (usually one) parent rows.

Debugging the problem, I discovered that the "DEPTNO" column name (without the underscore) was coming from the "Alias" property of the "Deptno" view object attribute on the detail "EmpView", which was an expert-mode view object. That is, the developer had overridden the default BC4J-generated SELECT statement with a manually-edited one. This is of course a totally supported operation, but it also was at the root of the problem as I explain next.

Looking at the EmpView in the view object editor, it indeed had a view attribute SQL alias expression of "DEPTNO" instead of "DEPT_NO". I also noticed that it's expert-mode SQL query looked like:

select emp.ename,
emp.empno,
:
etc.
:
emp.dept_no
from emp

So, a runtime error would happen if the developer did not hand-edit the view link's WHERE clause SQL, because the detail query would end up looking like this:

select * from (
select emp.ename,
emp.empno,
:
etc.
:
emp.dept_no
from emp) QRSLT WHERE :1 = DEPTNO

and the DEPTNO column alias used in the WHERE clause would not match with the expert-mode query's DEPT_NO expression in the select list.

The solution is to make the EmpView's "Deptno" view attribute SQL alias match the name of the corresponding column/expression selected in the expert-mode query. That means either adding an "AS DEPTNO" column alias in the expert-mode query to make it match, or editing the "DEPTNO" alias to read "DEPT_NO" instead.

After doing this, you might need to reset your view link component so that it goes back to being a non-user-customized one. You can verify that BC4J considers your viewlink to be an "expert mode" (i.e. user-customized SQL) view link by looking at the XML file related to that view link and noticing whether the element has an attribute named Where whose value is your user-customized where clause. To reset the view object, you can visit the "Source" panel and remove all of the attributes there. Then, shuttle the name of the association on which the view link will be based over into the selected list. Now, you should be back in business with a fully-functional, bidirectional, view-link-consistent-supported view link again.



2:45:31 PM    


Our QA team found a couple of issues with the ADF Toy Store demo when running under Linux, so I need to look into the problems. Since I don't presently have a Linux box of my own (and didn't want to disturb my "production" laptop that I use for development and demos that runs Windows XP Pro), I decided to install RedHat Linux 9.0 into a virtual PC on my box.

I've had good luck to date using Connetix Virtual PC 5.2 to test out beta versions of Visual Studio (including the just-released Visual Studio 2005 March 2004 Community Tech Preview that I hulked over the network this past weekend) to keep an eye on our competition, but until today hadn't tried creating a virtual PC with a non-Windows operating system. The RedHad installation is cranking away at present and looks to be going well. I hope this posting doesn't jinx it!

By using a virtual PC in full-screen mode, the audience has no idea that you're using a PC running on top of your real, base PC, so you can literally have many different environments all ready-to-run at a moment's notice. Quite nice.

In less than an hour (so says the install time estimate), I should have my virtual Linux box where I can verify if these Linux-specific UI issues are reproducible.


2:11:04 PM    


© Copyright 2008 Steve Muench.