gpt4 book ai didi

java - OneToMany 与 @EmbeddedId 和 kundera

转载 作者:行者123 更新时间:2023-11-29 07:34:53 25 4
gpt4 key购买 nike

我有两个类,我想使用 OneToMany 与 EmbeddedId 的关系(我正在使用 kundera 框架)我的传感器实体类:

public class SensorEntitie implements Serializable {
@EmbeddedId
private CompoundKey key;
@Column
private float temperature;
@Column
private float pressure;

@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
@JoinColumn(name="what I should to put here")
private List<PieceEntitie> pieces;
}
@Embeddable
public class CompoundKey
{
@Column
private String IdSensor;
@Column
private long date;
@Column(name = "event_time")
private long eventTime;

我的作品类实体

public class PieceEntitie implements Serializable{

/**
*
*/
@Id
private String IdPiece;
@Column
private double width;
@Column
private double height;
@Column
private double depth;

但是我怎样才能填补@JoinColumn 中的空白

最佳答案

我找到了解决方案:要使用与 EmbeddedId 的 OneToMany 关系,我应该声明 JoinColumns 和多个 JoinColumn

@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
@JoinColumns({
@JoinColumn(name = "idsensor", referencedColumnName = "idsensor"),
@JoinColumn(name = "date", referencedColumnName = "date"),
@JoinColumn(name = "event_time", referencedColumnName = "event_time")
})

关于java - OneToMany 与 @EmbeddedId 和 kundera,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37162156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com