persistence@glassfish.java.net

RE: Re: Code review for changes to allow colum aliases in Native Queries

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Tue, 12 Sep 2006 16:39:47 -0400

Without trying out some things I can't be sure there is an issue at all but TopLink supports allowing users to execute native SQL and having the results returned in the form of a Key/Value association list (like a result set but fetched). If users are using this now with aliases but are getting, and expecting, column names back we do not want to break them or at the very least have a story for them when we do break them.
--Gordon

-----Original Message-----
From: Mitesh.Meswani_at_Sun.COM [mailto:Mitesh.Meswani_at_Sun.COM]On Behalf Of
Mitesh Meswani
Sent: Tuesday, September 12, 2006 4:36 PM
To: persistence_at_glassfish.dev.java.net
Subject: Re: Code review for changes to allow colum aliases in Native
Queries


Gordon Yorke wrote:
> Hello Mitesh,
> I think this is fine for Essentials. Could you add a
> placeholder comment to the fix stating that "is should be
> reconsidered" before migrating the fix to other versions of TopLink
> with older native query support?
Done. Added following comment
            // Changed the following code to use
metaData#getColumnLabel() instead of metaData.getColumnName()
            // Reconsider whether to migrate this change to other
versions of Toplink with older native query support
            String columnName = metaData.getColumnLabel(index + 1);

I am curious what is the older native query support? What potential
issue do you see?

Thanks,
Mitesh
> --Thanks,
> --Gordon
>
> -----Original Message-----
> *From:* Mitesh.Meswani_at_Sun.COM [mailto:Mitesh.Meswani_at_Sun.COM]*On
> Behalf Of *Mitesh Meswani
> *Sent:* Tuesday, September 12, 2006 3:27 PM
> *To:* persistence
> *Subject:* Code review for changes to allow colum aliases in
> Native Queries
>
> Hi Tom,
>
> This is proposed fix for issues similar to one mentioned in
> 6398924
> <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6398924>. The
> issue is about using column aliases in native queries against
> Sybase using DataDirect drivers. We are currently hitting the same
> issue while certifying against Sybase using DataDirect driver.
>
> Toplink uses ResultSetMetadata#getColumnName()
> <http://download.java.net/jdk6/docs/api/java/sql/ResultSetMetaData.html#getColumnName%28int%29>to
> retrieve metadata of a result set where as according to jdbc spec,
> the correct one to use is ResultSetMetaData#getColumnLabel()
> <http://download.java.net/jdk6/docs/api/java/sql/ResultSetMetaData.html#getColumnLabel%28int%29>.
> Could you please review this. Shelly has run cts against Oracle,
> Derby and Sybase(DataDirect) with the fix successfully. I have run
> entity-persisetnce-tests against oracle and derby with the fix.
>
> $ cvs diff
> src/java/oracle/toplink/essentials/internal/databaseaccess/DatabaseAccessor.java
> Index:
> src/java/oracle/toplink/essentials/internal/databaseaccess/DatabaseAccessor.java
> ===================================================================
> RCS file:
> /cvs/glassfish/entity-persistence/src/java/oracle/toplink/essentials/internal/databaseaccess/DatabaseAccessor.java,v
> retrieving revision 1.5
> diff -r1.5 DatabaseAccessor.java
> 847c847
> < String columnName = metaData.*getColumnName*(index + 1);
> ---
> > String columnName = metaData.*getColumnLabel*(index
> + 1);
>
>
> Thanks,
> Mitesh
>
>
>
>