简体   繁体   English

JPA辅助表问题

[英]JPA Secondary Table Issue

I have a three tables: User, Course, and Test. 我有三个表:“用户”,“课程”和“测试”。

Course has a User foreign key and Test has a Course foreign key. 课程具有用户外键,而测试具有课程外键。 I am having trouble mapping the Test collection for each User since I need an intermediary step from User -> Course -> Test. 我在为每个用户映射Test集合时遇到了麻烦,因为我需要从User-> Course-> Test进行一个中间步骤。 I am trying to use a SecondaryTable since the User key for the Test is its associated Course row. 我正在尝试使用SecondaryTable,因为“测试”的“用户”键是其关联的“课程”行。

Am I on the right track using SecondaryTable or is there a way to use a JoinTable without the inverseJoinColumn? 我是否使用SecondaryTable处于正确的轨道,或者是否可以使用没有inverseJoinColumn的JoinTable?

Am I on the right track using SecondaryTable or is there a way to use a JoinTable without the inverseJoinColumn? 我是否使用SecondaryTable处于正确的轨道,或者是否可以使用没有inverseJoinColumn的JoinTable?

I don't think so, specifying secondary tables indicates that the entity's persistent data is stored across multiple tables, which is not exactly the case here. 我不这么认为,指定辅助表表示实体的持久性数据存储在多个表中,在此情况并非如此。

But it's hard to say more without seeing your entities, the relationships. 但是,如果不查看您的实体和关系,很难说更多。 And by the way, do you have the control of the database (ie can you change things)? 顺便说一句,您是否拥有数据库的控制权(即您可以更改内容)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM