Skip to content

SELECT HQL without entity alias results in SELECT COUNT(null) query #3744

Closed
@kotelnik

Description

@kotelnik

When writing e.g. this query:

@Query("SELECT id FROM Person")
Page<Long> findIdsPageable(Pageable pageable);

I get always only one page of data and I can see this in the log:

Hibernate: select p1_0.ID from Person p1_0 fetch first ? rows only
Hibernate: select count(null) from Person p1_0
2025-01-13 22:59:44,762 (main) WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] SQL Warning Code: -1003, SQLState: 01003
2025-01-13 22:59:44,763 (main) WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] warning: null value eliminated in set function

When using previous version of spring-data-jpa (3.3.7), I can see correct count(...) query and paging is working correctly:

Hibernate: select p1_0.ID from Person p1_0 fetch first ? rows only
Hibernate: select count(p1_0.ID) from Person p1_0

Is there something I should do differently to fix this issue?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions