有什么方法可以映射参考 table 中的外键名称吗? (多对多)

Is there any possible way to map the name of foreign key in reference table? (ManyToMany)

我根据这篇文章(https://spring.io/blog/2018/09/24/spring-data-jdbc-references-and-aggregates)

尝试在DDD上下文中实现参考table

我对 Jdbc 实体有不同的命名,因为我有另一个名为 Book 的域实体,它处理域逻辑。 (我决定解耦 Domain modelPersistence model,即 JdbcEntity,如下所示)

问题是 class 名称 BookJdbcEntity 自动映射为 book_author 中的外键名称:

"PreparedStatementCallback; bad SQL grammar [SELECT `book_author`.`AUTHOR_ID` AS `AUTHOR_ID` FROM `book_author` WHERE `book_author`.`BOOK_JDBC_ENTITY` = ?]; nested exception is java.sql.SQLSyntaxErrorException: (conn=845) Unknown column 'book_author.BOOK_JDBC_ENTITY' in 'where clause'",

有什么方法可以生成下面的 SQL 语句吗? (book_id 而不是 BOOK_JDBC_ENTITY

SELECT `book_author`.`AUTHOR_ID` AS `AUTHOR_ID` FROM `book_author` WHERE `book_author`.`book_id` = ?

Jdbc实体:

@Table("book")
data class BookJdbcEntity(
    @Id val id: Long,
    val title: String,
    val isbn: String,
    val pages: Int,
    val authors: Set<AuthorRef> = hashSetOf()
)

@Table("book_author")
data class AuthorRef(val authorId: Long)

架构:

CREATE TABLE IF NOT EXISTS book
(
    id    bigint(20)   NOT NULL,
    title VARCHAR(100) NOT NULL,
    isbn  varchar(100) not null,
    pages INTEGER      not null,
    PRIMARY KEY (id)
);

CREATE TABLE IF NOT EXISTS book_author
(
    book_id   bigint(20) NOT NULL,
    author_id bigint(20) NOT NULL,
    constraint book_id_fk foreign key (book_id) references book (id)
);

完成 @MappedCollection

@Table("book")
data class BookJdbcEntity(
    @Id val id: Long,
    val title: String,
    val isbn: String,
    val pages: Int,
    @MappedCollection(idColumn="book_id")
    val authors: Set<AuthorRef> = hashSetOf()
)