I'm trying to implement bidirectional polymorphic class.
Code:
public class Order{
...
@Any( metaColumn = @Column( name = "item_type" ), fetch=FetchType.EAGER )
@AnyMetaDef(
idType = "long",
metaType = "string",
metaValues = {
@MetaValue( value = "ItemA", targetEntity = ItemA.class ),
@MetaValue( value = "ItemB", targetEntity = ItemB.class )
} )
@JoinColumn( name = "item_id" )
Object item;
...
}
And trying to do somthing like the following
Code:
public class ItemA {
@OneToAny // like @OneToMany; in Order table there are "item_id" and "item_type" fields to distinguish ItemA and ItemB
List<Order> orders;
...
}
RoR support this kind of relationship, but I can't find it from Hibernate.
Inheritance with "Table per class" is not an option since it does not support the IDENTITY generator strategy.
Any solution for this?