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

[3028 byte] By [jdroza] at [2007-11-27 11:42:16]
# 1

I found the note in the EJB specs that clearly states that my issue has no solution at this time:

"Support for collections of embedded objects and for the polymorphism and inheritance of embeddable classes will be required in a future release of this specification."

EJB 3.0 specs - final release - persistence, page 23, note 10 in section 2.1.5

jdroza at 2007-7-29 17:43:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...