Hello,
I am working on Kodo to Hibernate migration in a legacy system.
I have the following code structure:
Code:
@Entity
@DiscriminatorValue(value = "S")
public class StructuredDataParameter extends Parameter {
private NFStructuredDataObject dataObject;
...
}
public interface NFStructuredDataObject {
...
}
public abstract class NFStructuredDataObjectAbstractImpl implements NFStructuredDataObject {
...
}
NFStructuredDataObjectAbstractImpl is extended by multiple entity classes.
Currently using Kodo (JDO), the field
dataObject was stored in database in
PARAMETER table in
DATA_OBJECT column as string value:
Code:
com.xyz.data.ChildrenData:com.xyz.data.ChildrenData-175829
where 175829 is an example primary key in table
CHILDREN_DATA and
com.xyz.data.ChildrenData is an entity class that extends
NFStructuredDataObjectAbstractImplKodo did it by default. How can I achieve such behavior in Hibernate?
I thought about @ManyToAny with @JoinFormula but it needs an additional discriminator column. Maybe there's a way to implement custom UserType that will resolve the target class and ID based on parts of the string value?
I need to use Hibernate 4.2.18 and since the schema is legacy I shouldn't change it.