i have the problem i have a base abstract Entity Station with Inheritance TABLE_PER_CLASS and three child Tables StationCompany StationAnalysis StationVariant
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS )
public abstract class Station {
@Entity
public class StationCompany extends Station {
@ManyToOne(optional = false, fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
private Company company;
@Entity
public class StationAnalysis extends StationCompany {
@ManyToOne(optional = false, fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
private Analysis analysis;
@Entity
public class StationVariant extends StationAnalysis {
@ManyToOne(optional = false, fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
private Variant variant;
public interface IStationCompanyRepository extends JpaRepository<StationCompany, Long> {
@Service
public class StationService implements IStationService<StationCompany> {
@Autowired
IStationCompanyRepository stationCompanyRepository;
Then i search findAll on StationCompany, hibernate make a query with union select. i will search only for the StationCompany entrys.
select x from ( select a from StationCompany union select b from StationVariant union select c from StationAnalysis )