I have an existing Hibernate Entity hierarchy I am working with. The Entities already use MappedSuperClass to inherit some common fields from base classes. In my scenario I need to inherit these fields as well and in addition need to leverage some composition via Embeddable feature in Hibernate.
For example, entity Car is marked as a MappedSuperClass and is extended by entity CarTypeA and CarTypeB.
Now CarTypeA and CarTypeB also happen to have some common fields between them which can be extracted into an Embeddable class( lets called it CommonCarStuff). CommonCarStuff looks as follows
@Embeddable
public class CommonCar
{
private String aCommonItem;
}
I am able to use this class in CarTypeA but at run time the INSERT query generated by Hibernate is incorrect. Instead of generating
INSERT INTO CAR_TYPE_A(A_COMMON_ITEM)..
the query generated states
INSERT INTO CAR_TYPE_A(COMMON_CAR_A_COMMON_ITEM)..
and I don't have this column mapped in my table causing the query to always fail - I have declared the Embedded class correctly.
Hope someone can help me out.
Thanks