{"record":{"id":"d287a771d7384596","repo":"pentaho/pentaho-kettle","slug":"unable-to-save-element-type-in-the-database-repository","errorCode":null,"errorMessage":"Unable to save element type in the database repository","messagePattern":"Unable to save element type in the database repository","errorType":"exception","errorClass":"MetaStoreException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KDBRMetaStoreElementType.java","lineNumber":48,"sourceCode":"  private String description;\n  private LongObjectId objectId;\n  private KettleDatabaseRepositoryMetaStoreDelegate delegate;\n\n  public KDBRMetaStoreElementType( KettleDatabaseRepositoryMetaStoreDelegate delegate, String namespace,\n    ObjectId namespaceId, String name, String description ) {\n    this.delegate = delegate;\n    this.namespace = namespace;\n    this.namespaceId = namespaceId;\n    this.name = name;\n    this.description = description;\n  }\n\n  @Override\n  public void save() throws MetaStoreException {\n    try {\n      delegate.insertElementType( this );\n    } catch ( Exception e ) {\n      throw new MetaStoreException( \"Unable to save element type in the database repository\", e );\n    }\n  }\n\n  @Override\n  public String getId() {\n    return objectId != null ? objectId.toString() : null;\n  }\n\n  @Override\n  public void setId( String id ) {\n    this.objectId = new LongObjectId( new StringObjectId( id ) );\n  }\n\n  public String getMetaStoreName() {\n    return metaStoreName;\n  }\n\n  public void setMetaStoreName( String metaStoreName ) {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/metastore/KDBRMetaStoreElementType.java#L30-L66","documentation":"KDBRMetaStoreElementType.save() persists an element type via delegate.insertElementType(); any exception is rethrown as MetaStoreException('Unable to save element type in the database repository', cause). It means the metadata element type could not be written to the repository's metastore tables (R_ELEMENT_TYPE etc.).","triggerScenarios":"metastore.createElementType(namespace, elementType) (which calls save()) when insertElementType throws — e.g. namespace missing, DB error, duplicate element type name in the namespace.","commonSituations":"Calling createElementType on a namespace that was never created; repository connection lost mid-session; metastore schema not created in the target repository.","solutions":["Check the chained cause exception for the actual DB error","Verify the parent namespace exists (createNamespace first) and is committed","Ensure the repository schema includes the metastore tables (upgrade/create the repository)"],"exampleFix":"// before\nmetaStore.createElementType(ns, elementType); // opaque failure\n// after\nif (metaStore.namespaceExists(ns)) {\n  metaStore.createElementType(ns, elementType);\n} else {\n  metaStore.createNamespace(ns);\n  metaStore.createElementType(ns, elementType);\n}","handlingStrategy":"try-catch","validationCode":"if (!metaStore.namespaceExists(namespace)) metaStore.createNamespace(namespace);","typeGuard":null,"tryCatchPattern":"try { elementType.save(); } catch (MetaStoreException e) { log(\"Element type save failed: \" + e.getCause()); throw e; }","preventionTips":["Create the namespace before adding element types","Confirm the metastore tables exist in the repository schema","Log the cause chain — insertElementType failures are usually DB-level"],"tags":["metastore","database","persistence","repository"],"backgroundTag":"database-write-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"}