I have a table structure like that :-
@Entity
@Table(name = "Load_Container_Tray")
public class LoadContainerTray {
@EmbeddedId
private LoadContainerTrayPK loadContainerTrayPK;
@MapsId("loadContainerPK")
@JoinColumns({
@JoinColumn(name = "dest_ebu_nbr", referencedColumnName = "dest_ebu_nbr"),
@JoinColumn(name = "outbound_load_id", referencedColumnName = "outbound_load_id"),
@JoinColumn(name = "dest_ebu_cntry_code", referencedColumnName = "dest_ebu_cntry_code"),
@JoinColumn(name = "ctnr_trackg_id", referencedColumnName = "ctnr_trackg_id") })
@ManyToOne
private LoadContainer loadcontainer;
}
@Embeddable 公共类LoadContainerTrayPK实现Serializable {
private static final long serialVersionUID = 3392075534159950245L;
@Basic
private LoadContainerPK loadContainerPK;
@Column(name = "load_unit_id", columnDefinition = "char(32)")
private String loadUnitId;
}
@Entity
@Table(name = "load_container")
public class LoadContainer {
@EmbeddedId
private LoadContainerPK loadContainerPK;
@MapsId("loadDestinationPK")
@JoinColumns({
@JoinColumn(name = "dest_ebu_nbr", referencedColumnName = "dest_ebu_nbr"),
@JoinColumn(name = "outbound_load_id", referencedColumnName = "outbound_load_id"),
@JoinColumn(name = "dest_ebu_cntry_code", referencedColumnName = "dest_ebu_cntry_code") })
@ManyToOne
private LoadDestination loadDestination;
@Column(name = "row_nbr")
private short rowNumber;
}
@Embeddable
public class LoadContainerPK implements Serializable {
private static final long serialVersionUID = 3392075534159950245L;
@Basic
private LoadDestinationPK loadDestinationPK;
@Column(name = "ctnr_trackg_id")
private String containerTrackingId;
}
public class LoadDestination {
@EmbeddedId
private LoadDestinationPK loadDestinationPK;
@MapsId("outboundLoadId")
@JoinColumn(name = "outbound_load_id", referencedColumnName = "outbound_load_id")
@ManyToOne
private OutboundLoad outboundLoad;
}
@Embeddable
public class LoadDestinationPK implements Serializable {
private static final long serialVersionUID = -3548089581858405303L;
@Column(name = "outbound_load_id")
private String outboundLoadId;
@Column(name = "dest_ebu_nbr")
private Integer destinationId;
@Column(name = "dest_ebu_cntry_code")
private String destEbuCntryCode;
}
@Entity
@Table(name = "outbound_load")
public class OutboundLoad {
@Id
@Column(name = "outbound_load_id", columnDefinition = "char(30)")
private String outboundLoadId;
@Column(name = "load_id")
private int loadId;
}
当我尝试在TOMEE服务器上部署应用程序时,我收到此错误: -
" org.apache.openejb.OpenEJBException:org.apache.openejb.OpenEJBRuntimeException:org.hibernate.AssertionFailure:映射@MapsId时引用实体上的意外嵌套组件:com.walmart.move.nim.outdoc.entity.LoadContainer:org .hibernate.AssertionFailure:映射@MapsId时引用实体上的意外嵌套组件:com.walmart.move.nim.outdoc.entity.LoadContainer。
有人可以帮我解决问题。
答案 0 :(得分:0)
我认为你应该注释
private LoadDestinationPK loadDestinationPK;
中的LoadContainerPK
@Embedded
代替@Basic
,为什么要使用@Basic
对其进行注释?如何将此类映射为基本类型?