Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Bug or misunderstanding ?(JPA getSingleResult() bug)
Bug or misunderstanding ? [message #1222564] Fri, 20 December 2013 19:26
Roger Spall is currently offline Roger SpallFriend
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'

Previous Topic:Configuring TimestampLockingPolicy via JPA Persistence Unit Property
Next Topic:Dynamic Moxy Exception for Enum Value Conversion
Goto Forum:
  


Current Time: Fri Apr 19 03:00:22 GMT 2024

Powered by FUDForum. Page generated in 0.01578 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top