Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot Spring数据jdbc-如何在多对多关系中设置模式_Spring Boot_Spring Data Jdbc - Fatal编程技术网

Spring boot Spring数据jdbc-如何在多对多关系中设置模式

Spring boot Spring数据jdbc-如何在多对多关系中设置模式,spring-boot,spring-data-jdbc,Spring Boot,Spring Data Jdbc,我在这里关注spring.io博客:https://spring.io/blog/2018/09/24/spring-data-jdbc-references-and-aggregates并在此处提供一个带有书籍和作者实体的示例SpringBoot应用程序: 我得到以下错误:没有为SQL参数“demobook”提供值:没有为键“demobook”注册值。 调试时注意到执行的SQL查询是:插入demo.book\u author(author,demo.book)值(:author,:demobo

我在这里关注spring.io博客:
https://spring.io/blog/2018/09/24/spring-data-jdbc-references-and-aggregates
并在此处提供一个带有书籍和作者实体的示例SpringBoot应用程序:

我得到以下错误:
没有为SQL参数“demobook”提供值:没有为键“demobook”注册值。

调试时注意到执行的SQL查询是:
插入demo.book\u author(author,demo.book)值(:author,:demobook)
,应该是
插入demo.book\u author(author,book)值(:author,:book)
。发生这种情况是因为我有
@表(“demo.book”)
作为
book
实体的注释。如果我删除表名中的
demo
模式,那么
book和authorstests
中的测试将正常进行


如何为表
Book
设置
schema

这是1.0.x版本中的一个错误。它固定为1.1

如果您将
spring boot starter父级升级到
2.2.0.M5
,您将获得
spring数据jdbc
版本
1.1.0.RC2
,其中包含修复程序

有了它,
@table
注释中的固定表名和
NamingStrategy
返回模式的方法一样有效

注意:然后您的配置需要扩展
AbstractJdbcConfiguration
,而不是
JdbcConfiguration

另一个注意事项:您的示例项目随后阻塞,因为
AuthorRef
需要到表
BOOK\u AUTHOR
的显式映射。
我马上会留下一份公关报告。

谢谢您的关注。我尝试使用
NamingStrategy
设置
schema
,但行为仍然相同。我在debug中看到insert查询仍然是相同的,即
book
列对于
book\u author
表被称为
demo.book
。如果您愿意,我可以将更改推送到我的github示例。再次感谢。我已将更改推送到此处:。您需要运行
SpringDataJDBCExample应用程序
。您应该注意到,
@Table
注释不再用于实体。但是,sql查询在所有查询中都以模式
demo
为前缀。对
book\u author
insert的sql查询仍然是
insert INTO demo.book\u author(author,demo.book)值(:author,:demobook)
。这是一个错误。我为它创建了一个你可能想看的问题:更新答案,还创建了一个PR。