-
Notifications
You must be signed in to change notification settings - Fork 376
Open
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
Description
I have an entity:
@Table("bookmarks")
public class Bookmark {
@Id
private Long id;
@Column("title")
private String title;
@Column("category_id")
private Long categoryId;
// setters & getters
}
Repository for Bookmark:
public interface BookmarkRepository extends CrudRepository<Bookmark, Long>, ListPagingAndSortingRepository<Bookmark, Long> {
Page<Bookmark> findByCategoryId(Long categoryId, Pageable pageable);
}
I am calling the findByCategoryId() method as follows:
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageable = PageRequest.of(pageNo-1, 10, sort);
Page<Bookmark> bookmarkPage = bookmarkRepository.findByCategoryId(1L, pageable);
This is throwing the following error:
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT COUNT(*) FROM "bookmarks" WHERE "bookmarks"."category_id" = ? ORDER BY "bookmarks"."id" DESC]
....
....
at com.sivalabs.bookmarker.BookmarkServiceTest.getBookmarksByCategoryId(BookmarkServiceTest.java:17)
Caused by: org.postgresql.util.PSQLException: ERROR: column "bookmarks.id" must appear in the GROUP BY clause or be used in an aggregate function
This was working fine with Spring Boot 3.5.8.
Attaching the reproducer sample app.
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged