Wednesday, April 25, 2012

Bug in ADF 11g R2 View Criteria Bind Variable Timestamp Type Configuration

I was blogging last year about new type configuration in ADF 11g R2 and issue with BigDecimal - ADF BC 11g R2 - Java Extended For Oracle Data Type Map. There is another bug related to Java Extended For Oracle Data Type Map - reproduced with Bind Variable defined from View Criteria for Timestamp type (JDeveloper 11g R2 generates different Timestamp in EO and for Bind Variable in VO).

Download fixed sample application - SearchDateApp.zip. This sample contains View Criteria with Date field (based on Timestamp type generated in EO). View Criteria renders out of the box ADF Query:


You can search by Date:


After the first search, click on calendar icon again. You will get error: java.lang.IllegalArgumentException: Cannot convert date of type java.sql.Timestamp to class oracle.jbo.domain.Timestamp:


Let's understand why this error happens - it can be very frustrating to developers and disappointing as well. Stay cool, try to debug it - compare generated Timestamp type in EO and VO Bind Variable.

Open EO and select HireDate attribute:


Open source XML and check generated type for HireDate. You will see that JDeveloper generates automatically oracle.jbo.domain.Timestamp:


Check what type was auto-generated for Bind Variable in VO (should be also Timestamp):


Open source XML - you will see java.sql.Timestamp was generated for Bind Variable:


There is no way to change this through the wizard, only possible through source XML view. This is what we call - JDeveloper magic, powered by artificial intelligence :) Obviously on runtime we get error, because generated types doesn't match.

Set Bind Variable to match type auto-generated in EO for date attribute - oracle.jbo.domain.Timestamp:


After this change, ADF Query will work without issues (at least related to described problem).

6 comments:

Jacob said...

Would it be wrong to change the datatype in all EO's to use java.sql.Timestamp instead of oracle.jbo.domain.Timestamp?

I'm wondering whether it i a mistake that EO's i generated with jbo Timetamp and not sql Timestamp?

Andrej Baranovskij said...

Its hard to say, but I saw java.sql.Timestamp related bugs in ADF UI. Its why I prefer to use oracle.jbo.domain.Date type.

Andrejus

Andrej Baranovskij said...

Another argument against java.sql.Timestamp, its just too much to go and change manually type of all Date attributes. This would mean to fix all Date attributes generated from DB tables.

Andrejus

Jonathan Hult said...

Thanks! This solved the issue for me.

Anonymous said...

HI Andrejus,
Can you please let me know if i have a column in database as varchar data type in JDEV how can i convert it to NUMBER?

Nasir said...

Thanks Andrejus,

Always helpful :)