In my DAO class, I have the following code to execute HQL selection query
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 –
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? |