Thursday, July 30, 2009

Range paging and Table Selected Row Bugs

In a default view object and default table in panel collection, when you scroll down and select a row and for any reason the table is submitted (button, reorder columns, detach), then the table returns to the first displayed page and the selected row was not visible.
But you could fix that if in the table properties you set displayRow="selected".
Except form the detach button that still reset the visible range to the start.

Bug1 :Yet when you set Range paging for tuning the view object the displayed (selected) row is lost many times (not always) when you submit page.


Bug2 :Also some times the selection listener of the table does not work and when you submit the previus selected row is selected


Bug3 : Last it seams that it execute many ranges in the query, not only when you scroll down, but also when you select a row.


So is this a bug?
or we should not use Range Paging in view objects used in table?

Test Case:

Tuesday, July 28, 2009

Iterating through View Object RowIterator Bug.(NOT ADF BUG, Development Bug)

The oldest bug in writing code is losing a row in an iterator.
This happens in ADF also.
I got embarrassed today saying to a developer 'RTFM' and been proven wrong. So I will first post some parts of the javadoc of RowIterrator and then a test case that proves it wrong.

When a Row Iterator is first opened or created, the currency is placed on an imaginary "slot" before the first row. This enables the user to invoke next() on a fresh new Row Iterator and retrieve the first row. For example, the following block of code will print attribute "Ename" for all employees (it does not miss the first row):
ApplicationModule myAM;
...
ViewObject myVO = myAM.findViewObject("MyEmpVO");
Row row;
while ((row = myVO.next()) != null)
{
System.out.println("Ename: " + row.getAttribute("Ename"));
}



void reset()
Moves the currency to the slot before the first row.
After this method, the current slot status will be SLOT_BEFORE_FIRST except in cases where this iterator is associated to an iterator binding in an ADF application which sets the currency to the first row in the iterator if available. A subsequent invocation of next() will cause the first row to become the current row.



So I created a View Object that only gets 3 rows and a method in application module that iterrates according to the above descriptions through the iterator and return the rows visited in a string:
public String checkIterations() {
String res = "Iterated through : ";
RowIterator view = this.getDepartmentsView1();
view.reset();
Row row;
while ((row = view.next()) != null) {
System.out.println("rownum: " + row.getAttribute("RowNum"));
res += row.getAttribute("RowNum") + " ";
}
return res;
}
When I run Application nodule and test this method, it goes through all rows as expected.


But if I open the view object (execute query) and then run this method again, the first row is never visited.


So is this a bug?

Test Case:
http://adfbugs.googlecode.com/files/TestIterator.zip

As my friends in the comments said its not a bug
Its a bad development practice (development bug) to do it as described above.

I should say RATFM (readh all the f... manual):

9.7.6 What You May Need to Know About Programmatic Row Set Iteration

Any time your application logic accesses a row set to perform programmatic iteration, you should use a secondary row set iterator when working with view object instances in an application module's data model, or view link accessor row sets of these view object instances, since they may be bound to user interface components.
To create a secondary iterator, use the createRowSetIterator() method on the row set you are working with. When you are done using it, call the closeRowSetIterator() method on the row set to remove the secondary iterator from memory.
Example 9-7 shows a typical application module custom method that correctly uses a secondary row set iterator for programmatic iteration, because the EmpView1 view object instance in its data model may be bound to a user interface (either now or at a later time).
Example 9-7 Using a Secondary Row Set Iterator in an Application Module Custom Method

// Custom method in an application module implementation classpublic
void doSomeCustomProcessing() {
ViewObject vo = getEmpView1();
// create secondary row set iterator with system-assigned name
RowSetIterator iter = vo.createRowSetIterator(null);
while (iter.hasNext()) {
Row r = iter.next();
// Do something with the current row.
}
// close secondary row set iterator
iter.closeRowSetIterator();}


Monday, July 27, 2009

View Criteria with Exists Optional Bug

I created a simple HR application with departments and Employees

In DepartmentsView i put query criteria, wanting departments that have Employees with old hire date.


The issue is that i want if no criterion is entered to show all departments. I thought since exist criterion is optional it should work. But no, it show anyway only departments that have Employees.


I think The solution would be easy for oracle developers if for view criteria where clause, instead of:
( (EXISTS(SELECT 1 FROM EMPLOYEES Employees WHERE ( ( ( Employees.HIRE_DATE < :inBeforeDate ) OR ( :inBeforeDate IS NULL ) ) ) AND (Departments.DEPARTMENT_ID = Employees.DEPARTMENT_ID))) )

when the exists criterion is optional to set:
( (EXISTS(SELECT 1 FROM EMPLOYEES Employees WHERE ( ( ( Employees.HIRE_DATE < :inBeforeDate ) OR ( :inBeforeDate IS NULL ) ) ) AND (Departments.DEPARTMENT_ID = Employees.DEPARTMENT_ID))) OR ( :inBeforeDate IS NULL ))

test case :

Sunday, July 26, 2009

Jdeveloper 11 r1 An unexpected severe error has ocurred in Jdeveloper

I often get this error while working on jdeveloper r1



I checked in forums and I saw that other people have it too.
http://forums.oracle.com/forums/thread.jspa?messageID=3609674&#3609674
and there is a bug 8677319 to track this issue.
But i am not sure its the same issue since i have different error log and it is not related with how much time you work with jdeveloper:
Invoking command: Insert[ from oracle.ide.ceditor.CodeEditor ]oracle.adfdtinternal.view.rich.binding.addin.PageToPageDefinitionSyncModelListener$SyncRunnable$1:26-Jul-2009 13:23:20 oracle.javatools.logging.LogUtils logWARNING: Exception in task oracle.adfdtinternal.view.rich.binding.addin.PageToPageDefinitionSyncModelListener$SyncRunnable$1@1e5a4d4 on model oracle.adfdtinternal.model.ide.navigator.nodes.PageDefinitionXmlModel@191c28b; txn name=non-dom transaction: oracle.adfdtinternal.view.rich.binding.addin.PageToPageDefinitionSyncModelListener$SyncRunnable$1 org.w3c.dom.DOMException: Not selection document:oracle.xml.parser.v2.XMLDocument@1f9ee33 at oracle.bali.xml.model.Selection.checkValidNode(Selection.java:572) at oracle.bali.xml.model.Selection.add(Selection.java:321) at oracle.bali.xml.model.Selection.set(Selection.java:287) at oracle.adfdtinternal.view.rich.binding.addin.PageToPageDefinitionSyncModelListener$SyncRunnable$1.performTask(PageToPageDefinitionSyncModelListener.java:118) at oracle.bali.xml.model.task.StandardTransactionTask.runThrowingXCE(StandardTransactionTask.java:172) at oracle.bali.xml.model.task.StandardTransactionTask.run(StandardTransactionTask.java:103) at oracle.adfdtinternal.view.rich.binding.addin.PageToPageDefinitionSyncModelListener$SyncRunnable.run(PageToPageDefinitionSyncModelListener.java:113) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Uncaught exceptionorg.w3c.dom.DOMException: Not selection document:oracle.xml.parser.v2.XMLDocument@1f9ee33 o.bali.xml.model.Selection.checkValidNode(Selection.java:572) o.bali.xml.model.Selection.add(Selection.java:321) o.bali.xml.model.Selection.set(Selection.java:287) o.adfdtinternal.view.rich.binding.addin.PageToPageDefinitionSyncModelListener$SyncRunnable$1.performTask(PageToPageDefinitionSyncModelListener.java:118) o.bali.xml.model.task.StandardTransactionTask.runThrowingXCE(StandardTransactionTask.java:172) o.bali.xml.model.task.StandardTransactionTask.run(StandardTransactionTask.java:103) o.adfdtinternal.view.rich.binding.addin.PageToPageDefinitionSyncModelListener$SyncRunnable.run(PageToPageDefinitionSyncModelListener.java:113) j.a.event.InvocationEvent.dispatch(InvocationEvent.java:209) j.a.EventQueue.dispatchEvent(EventQueue.java:597) j.a.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) j.a.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) j.a.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) j.a.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) j.a.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) j.a.EventDispatchThread.run(EventDispatchThread.java:122)


I manage to reproduce it in the same simple test case of previous post
http://adfbugs.googlecode.com/files/TestPPR.zip

The steps to reproduce it are:
Open TestPPR.jspx in source view
Open TestPPRPageDef.xml in source view
make any change in TestPPRPageDef.xml (i.e. id="Next" to id="Next1")
Go to TestPPR.jspx and click on diferent places of code
the error will appear then
I hope this help to solve this bug.

Friday, July 24, 2009

Partial Page Rendering ChangeEventPolicy="ppr" bug. (Fixed in 11.1.2)

While working on previews application I noticed something else.

Suddenly the result table in query page started to refresh every time I selected a row.

Also when I had scroll down in the results and selected a row the visible range whas returned back to the first page and I could not see the selected row.

I looked at the history of page and I didnt see anything strange, just I had added in a point a navigation button in the collection.
I checked the history in bindings and there I found the difference:

iterator Binds="EmployeesView1" RangeSize="25"
DataControl="AppModuleDataControl" id="EmployeesView1Iterator"
ChangeEventPolicy="ppr"


after removing ChangeEventPolicy="ppr" the table behaved correctly again.
I also notice in the detail log(-Djbo.debugoutput=console) the following:
[9421] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[9422] ! ERROR: Use of pinDataControl
[9423] ! is not supported. Pinning the !
[9424] ! DataControl will result in severe!
[9425] ! performance issues. !
[9426] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I don't know if it is related but it doesn't seems good.

So is this a bug?
We should not use ChangeEventPolicy="ppr" for iterators used in tables?
If not why it is set automatically when you drag and drop some iterator operations?

I reproduced the problem in a simple test case with just departments table
http://adfbugs.googlecode.com/files/TestPPR.zip

Metalink:
Bug No: 7233400 AUTOPPR: TABLE REREFRESHES UNNECESSARILY
Status: Scheduled for Future Release

Does not reproduce in Jdeveloper 11.1.2

Performance Tuning, Range Paging Last operation, bug

So I started working on Performance Tuning with Range Paging as Steve suggested.
In order to have more realistic performance tests I created a lot of employees (200000) using the following database procedure:

create or replace
PROCEDURE CREATE_EMPLOYEES AS
BEGIN
FOR i IN 1..200000 LOOP
Insert into employees (employee_id,
last_name,
email,
hire_date,
job_id)
select employees_seq.nextval as employee_id,
'auto' i as last_name,
'aut' i '@gmail.com' as email,
sysdate as hire_date,
'IT_PROG' as job_id
from dual;
END LOOP;
COMMIT;
END CREATE_EMPLOYEES;

So I tested Range Paging and I actually saw the difference in query page, while scrolling down the results of query criteria.
Then I go to Edit page and I press Last button. Then I get this error:
oracle.jbo.InvalidOperException: JBO-25084: Cannot call last() on row set EmployeesView1 because the access mode uses range-paging


I guess since its a jbo exception it is not a bug?
It doesn't say much for the user though...
So in order for performance we must not have a 'Last' button?
Or is better to use diferent view object for query and for edit?

Performance Tuning, Only up to row number, bug

In the same application I continue searching ways to do performance tuning so:
In the view object Tuning, in the frame called Retrieve from the database, I set
Only up to row number =10


I was expecting that only 10 rows would be retrieved from database by a filter like rownum<=10
but when I check the log (and database sql) I see that normal select is send to database:
[1214] SELECT Employees.EMPLOYEE_ID, Employees.DEPARTMENT_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE, Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Departments.DEPARTMENT_NAME, Departments.DEPARTMENT_ID AS DEPARTMENT_ID1 FROM EMPLOYEES Employees, DEPARTMENTS Departments WHERE Employees.DEPARTMENT_ID = Departments.DEPARTMENT_ID(+)
[1215] Bind params for ViewObject: EmployeesView1
[1216] DBTransactionImpl.mDefaultSparseArrayThreshold is 20
[1217] No Resource Bundle found but null value id:LOVUIHints_NullValueId is defined in an ListBinding Definition.
[1218] DCUtil, returning:oracle.adf.model.binding.DCParameter, for AppModuleDataControl
[1219] Changing iterator range size from :25 to :10
From what I know this select retrieves all rows from database and then somehow ADF shows only 10.
So wouldn't it be better performance for me to just put rownum<=10 in the where clause?