2
OpenOperaは、AttributeOverrideアノテーションを使用して継承したプロパティをマップしようとすると、スーパークラスのプロパティを見つけることができないというエラーをスローします。これを正しい方法でマップする方法がわかりません。OpenJPA:AttributeOverrideでスーパークラスのプロパティが見つかりません
エラー
Embedded property "Order.mailingAddress" declares a mapping override for "addressLine", but that is not a persistent property in the embedded type.
コード
@Embeddable
public class Address{
private String addressLine;
private String city;
private String state;
private String zip;
//getters and setters
}
@Embeddable
public class ExtendedAddress extends Address{
private String additionalAddressLine;
//getters and setters
}
@Entity
public class Order {
@Id
private id;
@OneToOne
private Customer customer;
@Embedded
@AttributeOverrides(value={
@AttributeOverride(name="addressLine",
[email protected](name="mailingAddressLine")),
@AttributeOverride(name="additionalAddressLine",
[email protected](name="mailingAddressLine2")),
@AttributeOverride(name="city",
[email protected](name="mailingAddressCity")),
@AttributeOverride(name="state",
[email protected](name="mailingAddressState")),
@AttributeOverride(name="zip",
[email protected](name="mailingAddressZip")),
})
private ExtendedAddress mailingAddress;
@Embedded
@AttributeOverrides(value={
@AttributeOverride(name="addressLine",
[email protected](name="billingAddressLine")),
@AttributeOverride(name="city",
[email protected](name="billingAddressCity")),
@AttributeOverride(name="state",
[email protected](name="billingAddressState")),
@AttributeOverride(name="zip",
[email protected](name="billingAddressZip")),
})
private Address billingAddress;
//getters and setters
//hashcode
//equals
}
SQL
CREATE TABLE Orders (
id INT PRIMARY KEY GENERATED ALWAYS,
mailingAddressLine VARCHAR(45) DEFAULT NULL,
mailingAddressLine2 VARCHAR(45) DEFAULT NULL,
mailingAddressCity VARCHAR(45) DEFAULT NULL,
mailingAddressState CHAR(2) DEFAULT NULL,
mailingAddressZip CHAR(9) DEFAULT NULL,
billingAddressLine VARCHAR(45) DEFAULT NULL,
billingAddressCity VARCHAR(45) DEFAULT NULL,
billingAddressState CHAR(2) DEFAULT NULL,
billingAddressZip CHAR(9) DEFAULT NULL
)
あなたは正しいです!どうもありがとうございました! –