Немного умолчал – имена отъезжают после редактирования @Embeddable
- создаем @Embeddable c @MetaProperty(mandatory = true, datatype = GeoCoordinateDatatype.NAME):
@MetaClass(name = "test$Foo")
@Embeddable
public class Foo extends EmbeddableEntity {
private static final long serialVersionUID = -4438342162318270661L;
@Column(name = "POINT")
<b> @MetaProperty(mandatory = true, datatype = GeoCoordinateDatatype.NAME)
protected Double point;</b>
public Double getPoint() {
return point;
}
public void setPoint(Double point) {
this.point = point;
}
}
- создаем Bar с Foo a и Foo b:
@Table(name = "TEST_BAR")
@Entity(name = "test$Bar")
public class Bar extends StandardEntity {
private static final long serialVersionUID = -6540842051688389706L;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "point", column = @Column(name = "A_POINT"))
})
protected Foo a;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "point", column = @Column(name = "B_POINT"))
})
protected Foo b;
public void setA(Foo a) {
this.a = a;
}
public Foo getA() {
return a;
}
public void setB(Foo b) {
this.b = b;
}
public Foo getB() {
return b;
}
}
- Редактируем GeoPoint, добавляем любое поле, например nonce. Тут пропадает @Column на point.
@MetaClass(name = "test$Foo")
@Embeddable
public class Foo extends EmbeddableEntity {
private static final long serialVersionUID = -4438342162318270661L;
@MetaProperty(mandatory = true, datatype = GeoCoordinateDatatype.NAME)
protected Double point;
@Column(name = "NONCE")
protected Double nonce;
public void setNonce(Double nonce) {
this.nonce = nonce;
}
public Double getNonce() {
return nonce;
}
public Double getPoint() {
return point;
}
public void setPoint(Double point) {
this.point = point;
}
}
- Сохраняем и смотрим Bar :
@Table(name = "TEST_BAR")
@Entity(name = "test$Bar")
public class Bar extends StandardEntity {
private static final long serialVersionUID = 6694097450420954251L;
@Embedded
@AttributeOverrides({
<b> @AttributeOverride(name = "point", column = @Column(name = "B_POINT")),
@AttributeOverride(name = "nonce", column = @Column(name = "B_NONCE"))
</b> })
protected Foo a;
@Embedded
@AttributeOverrides({
<b> @AttributeOverride(name = "point", column = @Column(name = "B_POINT")),
@AttributeOverride(name = "nonce", column = @Column(name = "B_NONCE"))</b>
})
protected Foo b;
public void setA(Foo a) {
this.a = a;
}
public Foo getA() {
return a;
}
public void setB(Foo b) {
this.b = b;
}
public Foo getB() {
return b;
}
}
a/b смотрят на B_POINT/B_NONCE