{"record":{"id":"1c525a503228ba99","repo":"spring-projects/spring-ai","slug":"failed-to-delete-documents-by-filter-1c525a","errorCode":null,"errorMessage":"Failed to delete documents by filter","messagePattern":"Failed to delete documents by filter","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-oracle-store/src/main/java/org/springframework/ai/vectorstore/oracle/OracleVectorStore.java","lineNumber":331,"sourceCode":"\n\t\ttry {\n\t\t\tString filterClause = this.filterExpressionConverter.convertExpression(filterExpression);\n\t\t\tString sql = String.format(\"DELETE FROM %s WHERE %s\", this.tableName, filterClause);\n\n\t\t\tif (logger.isDebugEnabled()) {\n\t\t\t\tlogger.debug(\"Executing delete with filter: \" + sql);\n\t\t\t}\n\n\t\t\tint deletedCount = this.jdbcTemplate.update(sql);\n\t\t\tif (logger.isDebugEnabled()) {\n\t\t\t\tlogger.debug(\"Deleted \" + deletedCount + \" documents matching filter expression\");\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tif (logger.isErrorEnabled()) {\n\t\t\t\tlogger.error(\"Failed to delete documents by filter: \" + e.getMessage(), e);\n\t\t\t}\n\t\t\tthrow new IllegalStateException(\"Failed to delete documents by filter\", e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<Document> doSimilaritySearch(SearchRequest request) {\n\t\ttry {\n\t\t\t// From the provided query, generate a vector using the embedding model\n\t\t\tfinal VECTOR embeddingVector = toVECTOR(this.embeddingModel.embed(request.getQuery()));\n\n\t\t\tif (logger.isDebugEnabled()) {\n\t\t\t\tthis.jdbcTemplate.batchUpdate(\"insert into debug(embedding) values(?)\",\n\t\t\t\t\t\tnew BatchPreparedStatementSetter() {\n\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void setValues(PreparedStatement ps, int i) throws SQLException {\n\t\t\t\t\t\t\t\torg.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(ps, 1,\n\t\t\t\t\t\t\t\t\t\tOracleType.VECTOR.getVendorTypeNumber(), embeddingVector);\n\t\t\t\t\t\t\t}","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-oracle-store/src/main/java/org/springframework/ai/vectorstore/oracle/OracleVectorStore.java#L313-L349","documentation":"OracleVectorStore.doDelete catches any exception during delete-by-id or delete-by-filter (JDBC execution of DELETE statements) and rethrows as IllegalStateException('Failed to delete documents by filter') with the cause attached. The root reason is in the chained cause and the error log.","triggerScenarios":"Calling vectorStore.delete(ids) or delete(filterExpression) when the JDBC delete fails — connection errors, SQL syntax from filter conversion, table/column missing, constraint violations, or lock timeouts.","commonSituations":"Oracle DB credentials/network misconfigured; filter rendered against nonexistent metadata columns; row locks held by other transactions; insufficient user privileges to delete from the vector store table.","solutions":["Read the chained cause (getCause()) for the exact SQLException and error code (e.g. ORA-00942 table not found, ORA-00054 locked).","Verify the Oracle connection config and that the vector store table exists with expected schema.","Check user privileges (DELETE on the table) and resolve row-lock contention.","Validate the filter expression maps to real metadata columns."],"exampleFix":"// before\n// ORA-00942 because table was created by another schema user\nvectorStore.delete(ids);\n// after\n// run as correct user or grant: GRANT DELETE ON vector_store TO ai_user;\nvectorStore.delete(ids);","handlingStrategy":"try-catch","validationCode":"// check table access before delete\njdbcTemplate.queryForObject(\"SELECT COUNT(*) FROM user_tab_privs WHERE table_name = 'SPRING_AI_VECTORS' AND privilege = 'DELETE'\", Integer.class);","typeGuard":null,"tryCatchPattern":"try {\n    oracleVectorStore.delete(idsOrFilter);\n} catch (IllegalStateException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof SQLException sqlEx) {\n        logger.error(\"Oracle delete failed: ORA-{}\", sqlEx.getErrorCode(), sqlEx);\n    }\n}","preventionTips":["Grant DELETE privileges on the vector store table to the application user","Confirm table/schema existence before startup","Keep delete transactions short to avoid ORA-00054 lock timeouts","Inspect getCause() for the exact ORA- error code"],"tags":["oracle","vector-store","delete","jdbc"],"backgroundTag":"sql-query-failed","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}