Puhong You (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZWQxZTI2NGJi...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16384?atlOrigin=eyJpIjoiZWQxZT...
) HHH-16384 (
https://hibernate.atlassian.net/browse/HHH-16384?atlOrigin=eyJpIjoiZWQxZT...
) org.hibernate.query.spi.AbstractSelectionQuery.setFirstResult() returns null causes
NullPointerException (
https://hibernate.atlassian.net/browse/HHH-16384?atlOrigin=eyJpIjoiZWQxZT...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Components: hibernate-core
Created: 27/Mar/2023 16:32 PM Priority: Major Reporter: Puhong You (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
In my DAO class, I have the following code to execute HQL selection query
String hql = "SELECT id FROM MyBean WHERE name = 'foo'";
List<Integer> queryResults =
session.createSelectionQuery(hql,
Integer.class).setFirstResult(0).setMaxResults(2).list();
When this query is invoked, the above line throws exception –
Original Exception:
java.lang.NullPointerException: Cannot invoke
"org.hibernate.query.SelectionQuery.setMaxResults(int)" because the return value
of "org.hibernate.query.SelectionQuery.setFirstResult(int)" is null
I debugged the code, and found that the following implementation of setFirstResult(int) in
AbstractSelectionQuery is invoked –
public SelectionQuery<R> setFirstResult(int startPosition) {
return null;}
I believe this is a bug, as all subclasses of AbstractSelectionQuery provides meaningful
implementation of this method. Should this method be marked as abstract instead? If the
setFirstResult() is not supported, maybe it’s better to throw an exception?
(
https://hibernate.atlassian.net/browse/HHH-16384#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16384#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100219- sha1:ac3e918 )