Tuesday, October 13, 2009

No inconsistency check after any Exception during posting data

During working on previous bug I found out that after any exception while posting Entity Data, inconsistency is not checked again.

Normally if 2 users query same row and change it then the user that commits last will get RowInconsistentException (JBO-25014)


But if second user get any exception while posting i.e. Foreign Key constraint exception, and then he correct it and commit again then he never gets a RowInconsistentException (JBO-25014)

To reproduce it in test case do the following

Run application and for ManagerId of department put an number that does not exist. Try to commit and you get constraint exception.

Open new instance of application and change anything and commit.

Go back to the first application correct the ManagerId to a valid value and commit.
You don’t get any RowInconsistentException

Is this a bug?

test case:

Friday, October 9, 2009

Open Locks in optimistic locking bug !!!

Open Locks in optimistic locking bug !!!

Yes it is possible, it was happening in our application and could not imagine why.
After research we found out that it was in the CustomDBTransactionImpl.
We use it to override doCommit in order to do staff after all data are posted but not yet committed according to :
Fusion Developer's Guide for Oracle ADF, D ADF Equivalents of Common Oracle Forms Triggers:

POST-FORMS-COMMIT
Execute code after Forms has "posted" all necessary rows to the database, but before issuing the data commit to end the transaction

If you want a single block of code for the whole transaction, you can override the doCommit() method in a custom DBTransactionImpl object and write code before calling the super.


I managed to reproduce it in a simple test case.

I just have Departments entity and view and an application module with CustomDatabaseTransactionFactory. In CustomDBTransactionImpl I override doCommit and throw an exception:

@Override
protected void doCommit() {
if (true){
throw new JboException("Exception in doCommit");
}
super.doCommit();
}

I run the application, make a change and press commit. I get the error:

Now the row is locked in the database!!!!

I run a new instance of the application i make a change and try to commit and I get:


If I try to do rollback before I throw the exception then the locks are lost of course but also all the changes made on page.

Is this a bug?
If not, is there an other way to check and throw exception, after data are posted to database and before commit, without locking?

Monday, October 5, 2009

unexpected error on graph preview when security enabled

I was trying to create graphs in a demo application with good results.
Jdeveloper 11 graphs are realy cool
Yet when i tried to put 1 in my application i got the known following error everytime i tried to preview graph in graph wisard.



i thought it was the selected data but, when i run application it seems ok




When i look at the messages tab of jdeveloper i see:

Caused by: oracle.security.idm.IMException: oracle.security.jps.JpsRuntimeException: The realm jazn.com does not exist. at oracle.security.jps.internal.idstore.xml.idm.IdmXmlIdentityStoreFactory.createIdmXmlIdentityStore(IdmXmlIdentityStoreFactory.java:182) at oracle.security.jps.internal.idstore.xml.idm.IdmXmlIdentityStoreFactory.createDefaultIdentityStore(IdmXmlIdentityStoreFactory.java:405) at oracle.security.jps.internal.idstore.xml.idm.IdmXmlIdentityStoreFactory.getIdentityStoreInstance(IdmXmlIdentityStoreFactory.java:196) at oracle.security.jps.internal.idstore.AbstractIdmIdentityStore.initStore(AbstractIdmIdentityStore.java:119) ... 60 more

So it had to do with security.

I enabled security in demo application and i have the same error again when i try to preview any graph from the wisard.

Is this a bug?

Test case:

http://adfbugs.googlecode.com/files/GraphTest.zip

user: tester

psw: welcome1

Tuesday, September 29, 2009

Tab selection and Enable User Customization on Session bug.

When you have enabled User Customization for duration of session then what ever user changes on a page it remains the same through out the session, ie. Disclosed panel boxes, advanced query criteria, visible columns of tables in panel collections etc.


The problem is that you cant customize which properties to be kept or not :
Fusion Developer's Guide for Oracle ADF & 34.3 Configuring User Customizations:
Note:
If you've enabled just session persistence, then all attribute values shown in Table 34-1 will be persisted to the session. There is no way to override this either globally or on an instance.

The bigger problem is that if you have some business logic about these components appearance or behavior you can’t override user settings.

We usually have some business logic about Disclosed tab in af:panelTabbed so I created this test case.

It’s a simple page that when you enter first tab should be disclosed and when you press button ‘Select Second tab’ second tab should be disclosed.

So I set disclosed property of First tab disclosed. Also on value change listener of button I run the following backing bean method:
public void SelectSecondTab(ActionEvent actionEvent) {
this.firstTab.setDisclosed(false);
this.secondTab.setDisclosed(true);
}

This work fine when I don’t have enabled User Customization.

But when I have enabled User Customization for duration of session then page always open with disclosed tab the one that I had selected the last time I used the page and backing bean method does not select the second tab.

Is this a bug?

Shouldn’t business logic methods override user customization settings?

Test case:
http://adfbugs.googlecode.com/files/TestTabSelection.zip

Wednesday, September 16, 2009

Range Paging and Restore Current Row After Rollback workaround

We use Steve Muench example for restoring current row after rollback is executed.
http://blogs.oracle.com/smuenchadf/examples/
http://otn.oracle.com/products/jdev/tips/muench/restorecurrencyonrollback/RestoreCurrentRowAfterRollback.zip
It was working fine until we started using Range Paging on view objects.
In view objects with range paging, if you select a row in the first page of range then rollback keeps the same row.

But if you select a row that is not on the first page of range, rollback gets you to the first row or throw a null pointer exception.

Reviewing the code of afterRollback method

public void afterRollback(TransactionEvent TransactionEvent) {
super.afterRollback(TransactionEvent);
if (currentRowKey != null) {
Key k = new Key(currentRowKey.getAttributeValues());
Row[] found = findByKey(k, 1);
executeQuery();
…

I noticed that it was calling executeQuery() method. I moved that call tbefore the findByKey method, and then rollback restores the current row after rollback even for view objects with Range Paging :

public void afterRollback(TransactionEvent TransactionEvent) {
super.afterRollback(TransactionEvent);
if (currentRowKey != null) {
executeQuery();
Key k = new Key(currentRowKey.getAttributeValues());
Row[] found = findByKey(k, 1);
…

Is this magic?

Do I miss something? Or it should be like that?

test case:
http://adfbugs.googlecode.com/files/TestRollbackRow.zip

Wednesday, September 9, 2009

Unsaved changes uncommittedDataWarning bug

I was reading JDeveloper 11g — Functional Patterns & Best Practices for unsaved changes
and decided to try it.

I created 2 task flows and 2 pages and navigation between them, normal and as dialog
In both pages i set and i run application.
I make a change in department name and press Employees Dialog.
The warning message for changes apear.

But the Employees Doesn't open as dialog!!??
When i try to return to Departments i get again the warning, even though no changes in this page and its a different task flow
So with this feature
you cannot use dialogs,
it does not rollback data
it does not depend on page or on task flow.
you cannot change the message
you cannot add custom logic on it
The only good thing about this feature is that the warning shows also when you try to close the explorer window. I wish it was working only then and it also released the application module.
test case:

Sunday, September 6, 2009

ExecuteEmptyRowSet and Range Paging. (Fixed in 11.1.2)

As andrejus showed you can reduce the time loading a page by executing Empty row set before page opens.
http://andrejusb.blogspot.com/2009/08/oracle-adf-tuning-preventing-sql-query.html


Yet this does not combine with Range Paging since getEstimatedRowCount give result in an empty row set when Range paging is used.


To test that i created an Employees view object and a method in application module that executes empty row set and estimate row count:


public long emptyRowSetCount(){
this.getEmployeesView1().executeEmptyRowSet();
return getEmployeesView1().getEstimatedRowCount();
}


this return 0 in default view object.


but if i set Employees view object Access Mode = Range paging then the method return the count of rows of the database.



The getFetchedRowCount return 0 in both cases but this is not exposed in the bindings and on the pages we usually use #{bindings.EmployeesView1Iterator.estimatedRowCount}.


In ViewObjectImpl java doc, the method executeEmptyRowSet does not have any comments, so its not clear what it does.


So i wander if this is an issue of executeEmptyRowSet or getEstimatedRowCount or Range Paging...


Test Case:
http://adfbugs.googlecode.com/files/TestEmptyRowSet.zip
Not Reproduced in jdeveloper 11.1.2