Skip to main content

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

Remember that EclipseLink weaves as well so there could be some
funkiness using another agent, but ya that's a good way to do it :)

On Fri, May 16, 2008 at 8:40 AM, natjohns <natjohns@xxxxxxxxxxx> wrote:
> 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
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>



-- 
./tch


Back to the top