@Table
@Entity
@Data
public class GaunamasSiunciamas {
@AttributeOverride(name = "siuntosNumeris", column = @Column(columnDefinition = "siuntos_numeris"))
@EmbeddedId
private Siuntinys siuntinys;
@AttributeOverride(name = "dezutesNumeris", column = @Column(columnDefinition = "dezutes_numeris"))
@Embedded
private Skyrelis skyrelis;
@AttributeOverride(name = "id", column = @Column(columnDefinition = "kurjeris_id"))
@Embedded
private Kurjeris kurjeris;
@AttributeOverride(name = "id", column = @Column(columnDefinition = "siuntejas_id"))
@Embedded
private Siuntejas siuntejas;
@AttributeOverride(name = "id", column = @Column(columnDefinition = "gavejas_id"))
@Embedded
private Gavejas gavejas;
private char siunciamaGaunama;
private java.sql.Timestamp ideta;
private java.sql.Timestamp paimta;
private int kurjerioPin;
private int gavejoPin;
}
链接到
@Entity
@Data
@Embeddable
public class Siuntinys implements Serializable {
@Column(name = "siuntos_numeris")
private @Id @GeneratedValue(strategy = GenerationType.AUTO)
int siuntosNumeris;
@ManyToOne
private Kurjeris kurjeris;
@ManyToOne
private Sandelys sandelys;
@OneToOne
private Siuntejas siuntejas;
@ManyToOne
private PastoDarbuotojas darbuotojas;
@ManyToOne
private Gavejas gavejas;
@ManyToOne
private Pristatymas pristaymoNumeris;
@ManyToOne
private PervezimasIsSandelioISandeli pervezimas;
private double siuntosSvoris;
private String siuntosBusena;
private char pristatymoTipas;
private char siuntimoTipas;
}
我得到一个错误:
调用init方法失败;嵌套异常为org.hibernate.mappingexception:找不到组件属性:siuntsumeris
有什么想法吗?两天没发现类似的东西
1条答案
按热度按时间vuv7lop31#
这就是问题所在:
属性
name
引用要重写的类的属性,但没有属性id
任何地方。依我看,你想用@Column
相反。不管怎么说,整个Map似乎都不正确。
Siuntinys
不能是可嵌入的实体。从您的Map来看,它似乎应该是一个实体,而不应该用作id。在一个类中Map的所有其他关联也是如此
@Embeddable
另一方面@ManyToOne
.我建议您阅读有关关联和标识符的hibernate orm文档。