Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6284958

@Query with allColumnsMapped=true doesnt work as expected.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • core-libs
    • b47
    • generic
    • generic
    • Verified

      JDK : 1.6.0-b40 with latest CVS checkout of JDBC4.0 workspace
      DB : ORCL.

      Execute a @Query with allColumnsMapped=true. When a field returned by SELECT statement is not present in the UDT class, SQLException is *NOT* being thrown. Not the expected behaviour.

      Here is a simple test to reproduce this problem.

      --- QueryTest.java ----------------------------------------------------

      import java.sql.*;

      public class QueryTest {
          
          Connection conn = null;
          Statement stmt = null;
          
          private void doSetup() {
              try {
                  Class.forName("com.inet.ora.OraDriver");
              }catch (ClassNotFoundException ex) {
                  System.err.println("Exception when loading JDBC driver : "+ex);
              }
       
              try {
                  conn = DriverManager.getConnection("jdbc:inetora:10.5.21.11:1521:ORCL", "ashwin", "ashwin");
                  stmt = conn.createStatement();
              }catch (SQLException ex) {
                  System.err.println("Exception : "+ex);
              }
              
              try {
                  stmt.executeUpdate("delete from query001");
                  stmt.executeUpdate("drop table query001");
              }catch (SQLException sqlEx) {}
                      
               try {
                  stmt.addBatch("create table query001 ( id number, firstName varchar2(32), lastName varchar2(32), age int, primary key (id))");
                  stmt.addBatch("insert into query001 values ( 1, 'Moises', 'Alou', 39 )");
                  stmt.addBatch("insert into query001 values ( 2, 'Mike', 'Matheney', 35 )");
                  stmt.addBatch("insert into query001 values ( 3, 'Omar', 'Visquel', 38 )");
                  stmt.executeBatch();
              }catch (SQLException ex) {
                  System.err.println("Exception when executing SQL :"+ex);
              }
          }
          
          private void doTest() {
              I_QueryTest query = null;
              DataSet<PersonDO> rows = null;
              
              try {
                  query = QueryObjectFactory.createDefaultQueryObject(I_QueryTest.class, conn);
              } catch (SQLException sqlEx) {
                  System.err.println("SQLException caught "+sqlEx.getMessage());
              }

              try {
                  rows = query.getAllPersons();
              }catch (Exception ex) {
                  if (ex instanceof SQLException)
                      System.out.println("TEST PASSED : SQLException thrown as expected");
                  else
                      System.err.println("Un-Expected Exception when executing @Query. : TEST FAILED");
                  
                  return;
              }
              finally {
                  //close connection
              }

              System.err.println("TEST FAILED: SQLException not thrown");
          }
          
          public static void main(String[] args) {
              QueryTest qtest = new QueryTest();
              qtest.doSetup();
              qtest.doTest();
          }
      }

      interface I_QueryTest extends BaseQuery {
          @Query(sql="SELECT id, lastName, age from query001", allColumnsMapped=true)
          DataSet<PersonDO> getAllPersons();
      }
      --- PersonDO.java ----------------------------------------------------
      public class PersonDO {
          public long id ;
          public String lastName ;
      }
      ----------------------------------------------------------------------
      ###@###.### 2005-06-13 23:49:18 GMT

            skaushiksunw Shreyas Kaushik (Inactive)
            aramanatsunw Ashwin Ramanathan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: