I have class BaseClass
@Entity
@Table(name = "childpart") @NoArgsConstructor
@AllArgsConstructor
@Data
public class BaseClass implements Serializable {
private static final long serialVersionUID = 1L;
@Id
String child_part_no;
}
I have two subclasses SubClassA and SubClassB
both class extending baseClass which has ID
@Entity
@Table(name = "childpart")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Data
public class SubclassA extends Pg6p0012_01ChildpartBaseQueryModel implements Serializable {
private static final long serialVersionUID = 1L;
private String component_qty;
}
and I am using JPA native query
@Query(value = "SELECT child_part_no, component_qty FROM childpart where part_no = :p_part_no", nativeQuery = true)
public List<ResultModel>getChildpart2Result(@Param("p_part_no") String p_part_no);
the structure of the project is like : single repository for all the queries which are using same table and there are different models for every query which is extending baseModel as shown above .
but the error is : Object [id=1J2143980000] was not of the specified subclass,loaded object was of wrong class
please provide solution.