Problems with Embedded classes mapping
Hi,
I'm experiencing problems for table generation with the following case:
a class declares two fields; one of them typed as a subclass of the other; both fields annotated with @Embedded; the subclass uses the annotation @AttributeOverride to avoid column names duplication.
When the tables are generated, one of the field (the most specialized one) is simply omitted by the JPA implementation...
To illustrate my problem, here is an example:
@Entity
publicclass Barimplements Serializable{
@Embedded
protected Foo foo =null;
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
protectedlong id = -1;
@Embedded
protected SubFoo subFoo =null;
public Bar(){
super();
}
// getters & setters
}
@Embeddable
publicclass Fooimplements Serializable{
@Column
protected String bar =null;
@Column
protected String foo =null;
public Foo(){
super();
}
// getters & setters
}
@Embeddable
@AttributeOverrides({
@AttributeOverride(name="bar", column=@Column(name="subbar")),
@AttributeOverride(name="foo", column=@Column(name="subfoo"))
})
publicclass SubFooextends Foo{
public SubFoo(){
super();
}
}
The generated table BAR contains only 3 columns: ID, FOO, BAR...
...and what I expect is two additionnal columns named SUBFOO & SUBBAR!
Can someone tell me: if I definitely need to go back to school (I'm obviously not an EJB expert), or how to make it work as I expect...?
Thanks
-Jerome

