Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] javax.persistence.NoResultException

I ended up using AOP to intercept the exception and return null because our previous ORM returned null and I didn't want to rewrite/redesign the entire system. I guess that's always an option.


James Sutherland wrote:
Unfortunately the JPA spec requires the exception.  However I agree that null
would be more useful, I would recommend you log an enhancement request in
Bugzilla for a query hint or persistence property that allows null to be
returned instead of an exception.

Leon Derks-2 wrote:

I did get the following exception:
javax.persistence.NoResultException: getSingleResult() did not retrieve
any entities.

This exception is correct, because there was nu such object in the db.
But if the object doesn't exist, I want to return a null object and not
a NoResultException

Is there a way how I can do that?


--- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink
Forums: TopLink , EclipseLink
Book: Java Persistence
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

eclipselink-users mailing list

Nathaniel A. Johnson
Principal Systems Analyst
Enterprise Services Integration
Division of Enterprise Software
Indiana University

Back to the top