admin管理员组文章数量:1287526
I'm not even quite sure how to quickly word my question for a title, but what I'm attempting to do is: I have a tank entity that contains a list of RefLines. There is also a list of tests which each contain parameter inside. What I'm trying to do is link the refLine to that parameter based on the foreign keys the refLine has (one to parameter and one to tank).
Example entry
line_id: 1 (pk)
param_id: 1 (fk)
tank_id: 1 (fk)
value: 10
color: red
I was originally thinking of placing a one to many in the parameter entity but I don't know how to link the tank_id from that to the tank itself so only the refLines for that tank exist within that list. I feel like I'm not making much sense but hopefully enough to get some help. I can add the controllers/services/repositories if needed but I'm not sure if it would help as I'm not having issues with the code yet, just trying to see if this is possible or if I have to do something weird to make it work.
I'm not even quite sure how to quickly word my question for a title, but what I'm attempting to do is: I have a tank entity that contains a list of RefLines. There is also a list of tests which each contain parameter inside. What I'm trying to do is link the refLine to that parameter based on the foreign keys the refLine has (one to parameter and one to tank).
Example entry
line_id: 1 (pk)
param_id: 1 (fk)
tank_id: 1 (fk)
value: 10
color: red
I was originally thinking of placing a one to many in the parameter entity but I don't know how to link the tank_id from that to the tank itself so only the refLines for that tank exist within that list. I feel like I'm not making much sense but hopefully enough to get some help. I can add the controllers/services/repositories if needed but I'm not sure if it would help as I'm not having issues with the code yet, just trying to see if this is possible or if I have to do something weird to make it work.
Share Improve this question asked Feb 24 at 5:59 TapialjTapialj 3452 gold badges3 silver badges11 bronze badges1 Answer
Reset to default 1IIUC the relations between your entities are:
1 tank to many reflines, 1 refline to 1 param.
in that case the refline entity should be
public class RefLine {
@Id
private int lineId;
@OneToOne
@JoinColumn(name = "param_id", referencedColumnName = "id")
private Param param;
@ManyToOne
@JoinColumn(name = "tankId", insertable = false, updatable = false)
private Tank tank;
...
本文标签: javaTrying to figure out how to joinlink 3 different spring boot entitiesStack Overflow
版权声明:本文标题:java - Trying to figure out how to joinlink 3 different spring boot entities - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741291318a2370563.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论