Hello,
I have a problem with a mapping for this structure that i designed
public abstract class A<T> {
private int discriminator_value = -1;
private T value;
//...
}
public class One extends A<String> {
public One(){
setDiscriminatorValue(1);
}
//...
}
public class Two extends A<BigDecimal> {
public Two(){
setDiscriminatorValue(2);
}
//...
}
public class Three extends A<Date> {
public Three(){
setDiscriminatorValue(3);
}
//...
}
public class TheTargetSolution {
private Long info1;
private Long info2;
private Long info3;
private A targetPojo;
//...
}
The table structure
THE_TARGET_SOLUTION_TABLE
- INFO_1 NUMBER(10)
- INFO_2 NUMBER(10)
- INFO_3 NUMBER(10)
- DISCRIM NUMBER(2)
- TEXT_A NVARCHAR2(200 BYTE)
- NUMBER_A NUMBER(10)
- DATE_A DATE
The main thing is that we need to have in TheTargetSolution the targetPojo that is type of A class and this class does not have mapping, (we need more info to entity and thees is no option to do this using relation many to many in this case all data has to be stored in one table) that is instance of type that apply to discriminator.
Resuming
When the DISCRIM column value is 1 the targetPojo should by type of One
When the DISCRIM column value is 2 the targetPojo should by type of Two
When the DISCRIM column value is 3 the targetPojo should by type of Three
Any suggestions ?