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.

Nate


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:
Hello

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?

Leon



-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/javax.persistence.NoResultException-tp17234760p17252886.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

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


Back to the top