Skip to content

Commit

Permalink
revert changes to gey surveys queries
Browse files Browse the repository at this point in the history
  • Loading branch information
wilczeqqqq committed Jun 4, 2023
1 parent 282c43e commit 368d083
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,4 @@ default Page<Survey> findAllWithEagerRelationships(Pageable pageable) {

@Query("select survey from Survey survey left join fetch survey.user where survey.id =:id")
Optional<Survey> findOneWithToOneRelationships(@Param("id") Long id);

@Query("SELECT DISTINCT s FROM Survey s LEFT JOIN FETCH s.questions")
List<Survey> findAllWithQuestions();

@Query("SELECT s FROM Survey s LEFT JOIN FETCH s.questions WHERE s.id = :surveyId")
Optional<Survey> findOneWithQuestions(@Param("surveyId") Long surveyId);
}
4 changes: 2 additions & 2 deletions src/main/java/com/pwr/students/web/rest/SurveyResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public ResponseEntity<Survey> partialUpdateSurvey(
public List<Survey> getAllSurveys(@RequestParam(required = false, defaultValue = "true") boolean eagerload) {
log.debug("REST request to get all Surveys");
if (eagerload) {
return surveyRepository.findAllWithQuestions();
return surveyRepository.findAllWithEagerRelationships();
} else {
return surveyRepository.findAll();
}
Expand All @@ -173,7 +173,7 @@ public List<Survey> getAllSurveys(@RequestParam(required = false, defaultValue =
@GetMapping("/surveys/{id}")
public ResponseEntity<Survey> getSurvey(@PathVariable Long id) {
log.debug("REST request to get Survey : {}", id);
Optional<Survey> survey = surveyRepository.findOneWithQuestions(id);
Optional<Survey> survey = surveyRepository.findOneWithEagerRelationships(id);
return ResponseUtil.wrapOrNotFound(survey);
}

Expand Down

0 comments on commit 368d083

Please sign in to comment.