Well, as per jpa:
/**
* Execute a SELECT query and return the query results
* as an untyped List.
* @return a list of the results
* @throws IllegalStateException if called for a Java
*
Persistence query language UPDATE or DELETE statement
* @throws QueryTimeoutException if the query execution exceeds
*
the query timeout value set and only the statement is
*
rolled back
* @throws TransactionRequiredException if a lock mode has
*
been set and there is no transaction
* @throws PessimisticLockException if pessimistic locking
*
fails and the transaction is rolled back
* @throws LockTimeoutException if pessimistic locking
*
fails and only the statement is rolled back
* @throws PersistenceException if the query execution exceeds
*
the query timeout value set and the transaction
*
is rolled back
*/
List getResultList();
If there is no result, wondering what's the point to return an empty list?
-Vivek
________________________________________
From:
kundera...@googlegroups.com [
kundera...@googlegroups.com] on behalf of Bytor99999 [
bytor...@gmail.com]
Sent: 24 August 2012 04:40
To:
kundera...@googlegroups.com
Subject: {kundera-discuss} Query returns no rows. In JPA would return empty List or Null
Right now I am running a query that would return no results, and therefore the List<Persons> that I assign the results to should be an empty List. I believe that is how it works in JPA and probably in the Spec. But my results is that the List is being set to null, or just not assigned as it is begins null. So now I have to do a Null pointer check everytime I run a query?
Thanks
Mark
________________________________
Impetus Ranked in the Top 50 India’s Best Companies to Work For 2012.
Impetus webcast ‘Designing a Test Automation Framework for Multi-vendor Interoperable Systems’ available at
http://lf1.me/0E/.
NOTE: This message may contain information that is confidential, proprietary, privileged or otherwise protected by law. The message is intended solely for the named addressee. If received in error, please destroy and notify the sender. Any use of this email is prohibited when received in error. Impetus does not represent, warrant and/or guarantee, that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.