Bug description If auto commit is disabled, jdbcTemplate.execute doesn't get committed and is rolled back: https://github.com/spring-projects/spring-ai/blob/690d242c22a70d5d3ebe40436fdbca8a1e481e44/vector-stores/spring-ai-pgvector-store/src/main/java/org/springframework/ai/vectorstore/pgvector/PgVectorStore.java#L421
Environment Spring AI v1.0.0-M6 Spring Boot 3.4.3 Java 17 PGVector store Hikari datasource with auto-commit disabled
Steps to reproduce Start an application with above configuration.
Expected behavior Schema should be correctly initialized.
Minimal Complete Reproducible example
Workaround
Commit manually:
jdbcTemplate.execute(
new ConnectionCallback<String>() {
public String doInConnection(Connection con) throws SQLException {
con.createStatement().execute("CREATE EXTENSION IF NOT EXISTS vector");
con.createStatement().execute("CREATE EXTENSION IF NOT EXISTS hstore");
con.createStatement().execute("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"");
con
.createStatement()
.execute(
String.format(
"""
CREATE TABLE IF NOT EXISTS %s (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
content text,
metadata json,
embedding vector(%d)
)
""",
"vector_store",
1536
)
);
con.commit();
return null;
}
}
);