core/src/test/java/org/apache/hop/core/database/DatabaseTest.java
@Test
  public void testGetLookupMetaCalls() throws HopDatabaseException, SQLException {
    when( meta.getQuotedSchemaTableCombination(any(), anyString(), anyString() ) ).thenReturn( "a" );
    when( meta.quoteField( anyString() ) ).thenReturn( "a" );
    when( ps.executeQuery() ).thenReturn( rs );
    when( rs.getMetaData() ).thenReturn( rsMetaData );
    when( rsMetaData.getColumnCount() ).thenReturn( 0 );
    when( ps.getMetaData() ).thenReturn( rsMetaData );
    Database db = new Database( log, variables, meta );
    Connection conn = mock( Connection.class );
    when( conn.prepareStatement( anyString() ) ).thenReturn( ps );

    db.setConnection( conn );
    String[] name = new String[] { "a" };
    db.setLookup( "a", name, name, name, name, "a" );
    for ( int i = 0; i < 10; i++ ) {
      db.getLookup();
    }
    verify( rsMetaData, times( 1 ) ).getColumnCount();
  }
/**
   * When using getLookup calls there is no need to make attempt to retrieve row set metadata for every call.
   * That may bring performance penalty depends on jdbc driver implementation. For some drivers that penalty can be huge
   * (postgres).
   * <p/>
   * During the execution calling getLookup() method we changing usually only lookup where clause which will not impact
   * return row structure.
   *
   * @throws HopDatabaseException
   * @throws SQLException
   */
When using getLookup calls there is no need to make attempt to retrieve row set metadata for every call.
That may bring performance penalty depends on jdbc driver implementation. For some drivers that penalty can be huge
(postgres).

During the execution calling getLookup() method we changing usually only lookup where clause which will not impact
return row structure.


When using getLookup calls there is no need to make attempt to retrieve row set metadata for every call . That may bring performance penalty depends on jdbc driver implementation . For some drivers that penalty can be huge ( postgres ) . During the execution calling getLookup () method we changing usually only lookup where clause which will not impact return row structure .
@Test
  public void testGetLookupMetaCalls() throws HopDatabaseException, SQLException {
    when( meta.getQuotedSchemaTableCombination(any(), anyString(), anyString() ) ).thenReturn( "a" );
    when( meta.quoteField( anyString() ) ).thenReturn( "a" );
    when( ps.executeQuery() ).thenReturn( rs );
    when( rs.getMetaData() ).thenReturn( rsMetaData );
    when( rsMetaData.getColumnCount() ).thenReturn( 0 );
    when( ps.getMetaData() ).thenReturn( rsMetaData );
    Database db = new Database( log, variables, meta );
    Connection conn = mock( Connection.class );
    when( conn.prepareStatement( anyString() ) ).thenReturn( ps );
    db.setConnection( conn );
    String[] name = new String[] { "a" };
    db.setLookup( "a", name, name, name, name, "a" );
    for ( int i = 0; i < 10; i++ ) {
      db.getLookup();
    }
    verify( rsMetaData, times( 1 ) ).getColumnCount();
  }
@ Test public void testGetLookupMetaCalls ( ) throws HopDatabaseException , SQLException { when ( meta . getQuotedSchemaTableCombination ( any ( ) , anyString ( ) , anyString ( ) ) ) . thenReturn ( "a" ) ; when ( meta . quoteField ( anyString ( ) ) ) . thenReturn ( "a" ) ; when ( ps . executeQuery ( ) ) . thenReturn ( rs ) ; when ( rs . getMetaData ( ) ) . thenReturn ( rsMetaData ) ; when ( rsMetaData . getColumnCount ( ) ) . thenReturn ( 0 ) ; when ( ps . getMetaData ( ) ) . thenReturn ( rsMetaData ) ; Database db = new Database ( log , variables , meta ) ; Connection conn = mock ( Connection . class ) ; when ( conn . prepareStatement ( anyString ( ) ) ) . thenReturn ( ps ) ; db . setConnection ( conn ) ; String [ ] name = new String [ ] { "a" } ; db . setLookup ( "a" , name , name , name , name , "a" ) ; for ( int i = 0 ; i < 10 ; i ++ ) { db . getLookup ( ) ; } verify ( rsMetaData , times ( 1 ) ) . getColumnCount ( ) ; }
When using getLookup calls there is no need to make attempt to retrieve row set metadata for every call.
When using getLookup calls there is no need to make attempt to retrieve row set metadata for every call .