[英]Use of SimpleJdbcCall to call stored procedure not using the current schema
I'm trying to use Spring JDBC Template to call a stored procedure inside a postgres database.我正在尝试使用 Spring JDBC Template 在 postgres 数据库中调用存储过程。 The connection is done from the yaml configuration file to indicate the current schema to use:
连接是从 yaml 配置文件完成的,以指示要使用的当前架构:
jdbc:postgresql://localhost:5455/userdb?currentSchema=customschema
Every queries done directly from jdbc template is using the correct current schema "customschema".直接从 jdbc 模板完成的每个查询都使用正确的当前模式“customschema”。 However, only executions done from SimpleJdbcCall to call a stored procedure is done in postgres default schema which is "public", and I can't understand why.
但是,只有从 SimpleJdbcCall 调用存储过程的执行是在“公共”的 postgres 默认模式中完成的,我不明白为什么。
Here is the execution code:这是执行代码:
new SimpleJdbcCall(jdbcTemplate).withFunctionName("custom_stored_procedure_name").execute();
While debugging, if I look at that jdbcTemplate.getDataSource().getConnection().getSchema()
, it returns the correct schema which is "customschema".在调试时,如果我查看
jdbcTemplate.getDataSource().getConnection().getSchema()
,它会返回正确的模式,即“customschema”。
I need to force the schema with .withSchemaName("customschema")
for this execution to work with the correct schema instead of "public".我需要使用
.withSchemaName("customschema")
强制架构,以便此执行使用正确的架构而不是“公共”。
I can't find any documentation online regarding this behavior.我在网上找不到有关此行为的任何文档。
Is it an issue from the library itself ?这是图书馆本身的问题吗?
为每个调用指定架构或将架构添加到搜索路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.