openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rakesh Jain (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-2352) Retrieving column index for non existing field throws SQLException (ignored) causing slowness in application server
Date Sat, 16 Mar 2013 01:48:12 GMT


Rakesh Jain commented on OPENJPA-2352:

Please also see the related problem I had raised on WebSphere:
> Retrieving column index for non existing field throws SQLException (ignored) causing
slowness in application server
> -------------------------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-2352
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.1.1
>         Environment: All OS, I have tried with DB2 but problem may exist for all databases.
>            Reporter: Rakesh Jain
>              Labels: ResultSetResult,, exception, ignored, jdbc,
> When we have defined NamedNativeQuery and the query contains let's say 4 columns. Now
if we have a resultClass associated to that query which is simply a POJO having let's say
five fields, four of which are mapped to the 4 columns of the NamedNativeQuery, but the fifth
one is not (after all it is POJO), the JPA tries to retrieve column index for that fifth field,
and that throws SQL exception. The JPA code though ignores this exception, returning zero
for column index. However, because an exception is throws, the application server in which
this code is executing captures it and logs it in its corresponding logs. This causes the
population of the result bean slow, and very slow if there are 4-5 or more fields unmapped.
> Here's the code fragment from where
this is happening.
> /**
> * Return the 1-based result set index for the given column or id, or a
> * non-positive number if the column is not contained in this result.
> */
> protected int findObject(Object obj, Joins joins)
> throws SQLException {
> try {
> String s1 = obj.toString();
> DBIdentifier sName = DBIdentifier.newColumn(obj.toString());
> return getResultSet().findColumn(_dict.convertSchemaCase(sName));
> } catch (SQLException se) {
> return 0;
> }
> }
> Moreover, this same method is called multiple times for each field, multiplying the problem.
> I would think a better approach would be to use ResultSetMetaData to retrieve all the
column names and indexes, cache them and simply return from that cache in the findObject method.
> Is there any reason to keep it like this and not change to use metadata?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message