I am trying to use this mapping:
@Entity
@Table(name="ecc.\"RATE\"")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType= DiscriminatorType.STRING)
public abstract class Rate extends GenericBusinessObject {
...
}
@Entity
@DiscriminatorValue("E")
public class EntranceRate extends Rate {
@ManyToOne
@JoinColumn(name = "\"RATES_GRID_ID\"")
protected RatesGrid ratesGrid;
...
}
@Entity
@Table(name="ecc.\"RATES_GRID\"")
public class RatesGrid extends GenericBusinessObject {
@OneToMany(mappedBy = "ratesGrid", targetEntity = EntranceRate.class, fetch=FetchType.LAZY)
private List<EntranceRate> entranceRates;
}
When I try to access my list entranceRatesfrom an object ratesGrid, I get this error:
Object with id: 151 was not of the specified subclass: com.ecc.bo.rate.EntranceRate (loaded object was of wrong class class com.ecc.bo.rate.AnnualRate)
Looking at the generated sql, I did not find a trace of "discriminator =" in the where clause. What am I doing wrong?
I use the PostGreSQL and Hibernate database as a JPA provider.
source
share