query.uniqueResult() potentially generates out of memory by calling list()
--------------------------------------------------------------------------
Key: HHH-3432
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3432
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.3.0.CR2, 3.2.6
Reporter: Emmanuel Bernard
calling list() while the user expects a single result has potential major flow: it's
easy to trigger an out of memory situation where nobody would expect it...
like getSingleResult("select CURRENT_TIME from
AN_ENTITY_CONTAINING_ZILLIONS_OF_RECORDS") ;
(and it is also a performance problem when it doesn't trigger the out of heap space...
and a design issue: why fetching something the caller is not asking for ? with all the
consequences on the cache...)
fix:
Something like that
if (maxResults != 1) query.setMaxResults( 2 ); //avoid OOME if the list is huge
List result = query.list();
if ( maxResults != -1 ) query.setMaxResults( maxResults ); //put back the original value
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira