-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: org.hibernate.ejb.Query.getSingleResult() does not conform
PostPosted: Wed Jun 21, 2006 8:19 am 
Regular
Regular

Joined: Fri Jan 20, 2006 9:38 am
Posts: 61
Location: Notts, UK
org.hibernate.ejb.Query.getSingleResult() throws
Code:
javax.persistence.NoResultException
if the requested entity is not found.

The specification says it should throw
Code:
javax.persistence.EntityNotFoundException


See http://www.hibernate.org/hib_docs/ejb3- ... gleResult()

The source for the method looks like this:

Code:
   public Object getSingleResult() {
      try {
         Object result = query.uniqueResult();

         if ( result == null ) {
            throw new NoResultException( "No entity found for query" );
         }

         return result;
      }
      catch (NonUniqueResultException e) {
         throw new javax.persistence.NonUniqueResultException( e.getMessage() );
      }
   }


Will this be changed, or should I change my code to catch the incorrect exception, and it will work forever?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.