{"record":{"id":"5458e88bc5480852","repo":"pentaho/pentaho-kettle","slug":"unable-to-retrieve-auto-increment-of-combi-insert-key-meta-5458e8","errorCode":null,"errorMessage":"Unable to retrieve auto-increment of combi insert key :  + meta.getTechnicalKeyField()","messagePattern":"Unable to retrieve auto-increment of combi insert key :  \\+ meta\\.getTechnicalKeyField\\(\\)","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/combinationlookup/CombinationLookup.java","lineNumber":634,"sourceCode":"      // INSERT NEW VALUE!\n      data.db.setValues( data.insertRowMeta, insertRow, data.prepStatementInsert );\n\n      debug = \"Insert row\";\n      data.db.insertRow( data.prepStatementInsert );\n\n      debug = \"Retrieve key\";\n      if ( isAutoIncrement() && databaseMeta.supportsAutoGeneratedKeys() ) {\n        ResultSet keys = null;\n        try {\n          keys = data.prepStatementInsert.getGeneratedKeys(); // 1 key\n          if ( keys.next() ) {\n            val_key = new Long( keys.getLong( 1 ) );\n          } else {\n            throw new KettleDatabaseException( \"Unable to retrieve auto-increment of combi insert key : \"\n              + meta.getTechnicalKeyField() + \", no fields in resultset\" );\n          }\n        } catch ( SQLException ex ) {\n          throw new KettleDatabaseException( \"Unable to retrieve auto-increment of combi insert key : \"\n            + meta.getTechnicalKeyField(), ex );\n        } finally {\n          try {\n            if ( keys != null ) {\n              keys.close();\n            }\n          } catch ( SQLException ex ) {\n            throw new KettleDatabaseException( \"Unable to retrieve auto-increment of combi insert key : \"\n              + meta.getTechnicalKeyField(), ex );\n          }\n        }\n      }\n    } catch ( Exception e ) {\n      logError( Const.getStackTracker( e ) );\n      throw new KettleDatabaseException( \"Unexpected error in combination insert in part [\"\n        + debug + \"] : \" + e.toString(), e );\n    }\n","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/combinationlookup/CombinationLookup.java#L616-L652","documentation":"KettleDatabaseException wrapping a SQLException raised while calling keys.getLong(1)/getGeneratedKeys() in combiInsert — i.e. the JDBC driver itself threw while trying to retrieve the auto-increment value of the just-inserted combi (dimension) row, as opposed to simply getting no rows back.","triggerScenarios":"After the combi insert, data.prepStatementInsert.getGeneratedKeys() or iterating the keys ResultSet throws SQLException; the catch block rethrows with the technical key field name and the SQL exception as cause.","commonSituations":"Driver does not support generated keys and throws instead of returning an empty set; connection lost between insert and key retrieval; statement closed or feature not implemented by the JDBC driver.","solutions":["Inspect the wrapped SQLException cause; if it is 'feature not supported', switch tech key creation from auto-increment to sequence or table-maximum in the step settings.","Upgrade or correct the JDBC driver for your database.","Verify the database connection is still alive (network/firewall timeouts).","Avoid using getGeneratedKeys-requiring drivers with this step; use a sequence-based key."],"exampleFix":"// before: 'use autoinc' checked with a driver lacking generated-keys support\n// after: uncheck auto-increment and select 'use table maximum' / a named sequence\n//        for the technical key in the CombinationLookup step dialog.","handlingStrategy":"try-catch","validationCode":"// verify driver supports generated keys before relying on autoinc\n// DatabaseMetaData md = conn.getMetaData();\n// log.info(\"Driver: \" + md.getDatabaseProductName() + \" \" + md.getDriverVersion());","typeGuard":null,"tryCatchPattern":"try { /* run */ } catch (KettleDatabaseException e) {\n  if (e.getCause() instanceof SQLException) {\n    log.error(\"Generated key retrieval failed: \" + e.getCause().getMessage());\n  }\n}","preventionTips":["Validate driver support for RETURN_GENERATED_KEYS in a smoke test.","Use sequence-based tech keys on Oracle/PostgreSQL instead of autoinc.","Monitor connection health to avoid mid-statement breakage."],"tags":["database","jdbc","auto-increment","sqlexception"],"backgroundTag":"sql-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}