简体   繁体   中英

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. I am trying to use a SecondaryTable since the User key for the Test is its associated Course row.

Am I on the right track using SecondaryTable or is there a way to use a JoinTable without the inverseJoinColumn?

Am I on the right track using SecondaryTable or is there a way to use a JoinTable without the inverseJoinColumn?

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)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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