persistence@glassfish.java.net

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:24:07 -0400

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?
--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. 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() to retrieve metadata of a result set where as according to jdbc spec, the correct one to use is ResultSetMetaData#getColumnLabel(). 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