Bug or misunderstanding ? [message #1222564] |
Fri, 20 December 2013 19:26 |
Roger Spall Messages: 17 Registered: January 2013 |
Junior Member |
|
|
Not sure if this is a bug, or misunderstanding but it is certainly a pain in the proverbial!
From my understanding of the JPA specification, the Query.getSingleResult() method correctly throws an exception if more than one, or no result is found, however...
Query.getSingleResult() is a 'little dumb' in that it will read all objects returned by a query BEFORE it throws the 'more than one result' exception! This wouldn't be such a big deal, except in a couple of cases while converting old Toplink (ReadObjectQuery) code to Eclipselink our server kept crashing with OutOfMemory errors! The reason was ultimately a bad query which returned a huge number of objects while using the getSingleResult() method.
The same code worked fine as a Toplink ReadObjectQuery, because it just read and returned the first matching object. Unfortunately as a 'getSingleResult()' method the Eclipselink library tries to read in ALL matching objects before it throws the 'more than one result exception'. I think it would be a little smarter if it threw the exception after reading the 2nd matching result?
I am using Eclipselinkversion '2.5.0.v20130507-3faac2b'
|
|
|
Powered by
FUDForum. Page generated in 0.29906 seconds