Saturday, December 27, 2008

Bug in Create/Edit View Criteria Wizard (JDeveloper 11g)

There is one (known) funny bug in Create/Edit View Criteria wizard (ADF BC 11g, View Object), I will describe it today. Bug I'm describing today is related to Bind Variables defined while declaring View Criteria in ADF BC View Object. For some reason, wizard can loose correct names for Bind Variables and reassign wrong ones, this will cause unexpected behavior on runtime.

How to reproduce:
  1. Open your View Object, go to Query section and click Create new view criteria sign. Create View Criteria wizard will be opened
  2. In Edit Query Criteria tab, press Add Item button. As Attribute choose EmployeeId and for Operand select Bind Variable option
  3. Press New button, available next to Parameter field
  4. In Bind Variable wizard, provide employeeIdVar for Name and Number for Type. Press OK
  5. Press OK in Create View Criteria wizard - EmployeesViewCriteria is created and Bind Variable is defined as well. So far its okej
  6. Now let's say we will want to modify our View Criteria. Click Edit selected view criteria sign for EmployeesViewCriteria. Edit View Criteria dialog will be opened
  7. Press Add Item button and change Attribute for added item to FirstName. For Operand slect Bind Vraiable option
  8. Press New button, available next to Parameter field
  9. In Bind Variable wizard, provide firstNameVar for Name and String for Type. Press OK
  10. Everything looks okej, so press OK in Edit View Criteria wizard in order to update EmployeesViewCriteria
  11. Save your View Object
  12. Now, reopen Edit View Criteria wizard by clicking on Edit selected view criteria sign
  13. I know, you will be surprised now, but you will see that for FirstName item is assigned employeeIdVar Bind Variable. Here is a Bug - correct Bind Variables are not stored correctly, simply first one from the list is assigned after you closing Edit View Criteria wizard:

This means, if developer will forget to fix this, on runtime same Bind Variable will be used for both parameters. In this case Number type Bind Variable is assigned to String type parameter.

On runtime, when user will select value for EmployeeId parameter, same value will applied for FirstName parameter:

WHERE part of SQL statement looks pretty funny as well:

WHERE ( ( ( ( Employees.EMPLOYEE_ID = :employeeIdVar ) OR ( :employeeIdVar IS NULL ) ) AND ( ( UPPER(Employees.FIRST_NAME) LIKE UPPER( :employeeIdVar || '%') ) OR ( :employeeIdVar IS NULL ) ) ) )

Workaround (not smart enough):
  • If you are using Edit View Criteria wizard and adding new Items with new Bind Variables, always reopen (after first change) this wizard and check if Bind Variables are not reassigned. If they are, change them back and close wizard - next time reassignment for already defined items will not be done

Spanish Summary:

Titulo: Bugs en el asistente de Jdeveloper 11g cuando se crean formularios de ALTA y EDICION.

Resumen: En este post se reproduce un error que genera el asistente de jdeveloper cuando se construyen formularios. Este articulo incluye la manera de solucionar este inconveniente.


Anonymous said...

Thank you Andrejus.

Using your scenario, steps 1 to 13, I have been able to reproduce the issue, and the "workaround" you suggest fixes things.
Do you have a bug number for this?

Jan Vervecken

Andrej Baranovskij said...

Hi Jan,

Thanks for confirming !

No, there was no time for me to fill bug in Metalink. If you can report it on Metalink, I would appreciate.


Anonymous said...

hi Andrejus


Jan Vervecken

Andrej Baranovskij said...

Thanks !

Anonymous said...

Did this today and its fixed, worked super fine!

Andrej Baranovskij said...

Thats great, improvements in new JDev release :)