I have an entity class as follows. What I need is, I need to use generics, and by using it I need to pass some classes that extend the SomeInfo class and persist a common field inside the SubClass table and when returning data I can populate T parameter and send it easily. But I can't extend SomeInfo class directly because it contains fields that I don't need to be created in the SubClass table and even I don't need to use the Inheritance Single Table solution. I have tried using @AttributeOverride but it threw an error and I used @Type annotation and the error was gone, but the field info_name isn't created.
@Entity
public class SubClass<T extends SomeInfo> extends ParentClass {
@Type(type = "com.package.SomeInfo")
@AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "info_name", nullable = false))
})
private T info;
}
@MappedSuperClass
public abstract class SomeInfo extends ParentClass {
// some fields
}
Is there a way to achieve what I need? Thanks in advance.