我想实现嵌套一个标记为 Embeddable 的元素,该元素已经嵌入了元素:
@Embeddable
public class A implements Serializable {
private int a;
private int b;
}
@Embeddable
public class B implements Serializable {
@Embedded
protected A sum;
@Embedded
protected A value;
... }
@Entity
public class C implements Serializable{
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "sum.a", column =
@Column(name = "SUM_COL_A", precision = 12, scale = 2, nullable = false)),
@AttributeOverride(name = "sum.b", column =
@Column(name = "SUM_COL_B", precision = 12, scale = 2, nullable = false)),
@AttributeOverride(name = "value.a", column =
@Column(name = "VALUE_COL_A", precision = 12, scale = 2, nullable = false)),
@AttributeOverride(name = "value.b", column =
@Column(name = "VALUE_COL_B", precision = 12, scale = 2, nullable = false))
private B property;
})
}
执行后,我创建了两列(VALUE_COL_A 和 VALUE_COL_B),前两列根本不存在。
我错过了什么?谢谢