JAVA_CAT
JAVA_CAT

Reputation: 859

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property languageId found for type Project

I have two Entity class as shown below. Using JPARepository how can I findProjectByProjectIdAndLanguageId.

@Entity
public class ProjectDetails {

    @Id
    private int projectId;
    private String projectDescription;
    private int languageId;


}


@Entity
public class Project {

    @Id
    private int projectId;
    private String projectName;
    private LocalDate projectStartDate;
    private LocalDate projectEndDate;
    private String projectStatus;

    @OneToOne
    private ProjectDetails projectDetails;


}


@Repository
public interface ProjectRepository extends JpaRepository<Project, Integer> {

    public List<Project> findProjectByProjectIdAndLanguageId(int projectId , int languageId);

}

I am getting below error when I start my spring boot application.

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property languageId found for type Project!

Upvotes: 0

Views: 1413

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 82008

If you want to filter on properties not on the aggregate root you'll have to provide the full path. The following should work.

public List<Project> findProjectByProjectIdAndProjectDetailsLanguageId(int projectId , int languageId);

Upvotes: 2

Related Questions