Reputation: 435
I am trying to use projection class in spring data rest repository method. But I am getting Couldn't find PersistentEntity error when trying to hit the endpoint. Not sure why its happening. Can someone please throw some light on it...
error
org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class com.bugfix.api.provider.entity.projections.IncidentLatestProjection!
Repo Class
public interface UpdatedIncidentRepository extends CrudRepository<UpdatedIncident, Integer> {
@Query(" select new com.bugfix.api.provider.entity.projections.IncidentLatestProjection(" +
"d.IncidentId,d.IncidentName,d.alm) from UpdatedIncident d" +
" inner join Updatedparent u on u.parentId=d.parent.parentId where d.parent.parentId=:parentId ")
List<IncidentLatestProjection> testing(@Param("parentId") Integer parentId);
}
Projection Class
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IncidentLatestProjection {
private Integer IncidentId;
private String IncidentName;
private String alm;
}
Entity Class
@Entity
@Table(name="Incident_v")
@NoArgsConstructor
@AllArgsConstructor
@Data
public class UpdatedIncident implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="Incident_id")
@JsonProperty("IncidentId")
private Integer IncidentId;
@Column(name="Incident_name")
private String IncidentName;
private String alm;
//bi-directional many-to-one association to parent
@ManyToOne
@JoinColumn(name="parent_id")
private Updatedparent parent;
}
Upvotes: 0
Views: 40