2 Replies Latest reply on Mar 22, 2007 6:51 AM by mbrunnert

    Changed behaviour of getSingleResult?

    heinrich

      Hi,

      i have a question concerning the method "getSingleResult()".
      The intended behaviour of the method was up to today, that if the underlying query returns more than one result, the mthod returns the first of them.
      Only in case of no results, a NoResultFound Exception is thrown.

      But, as we found out today, when there are at least two results we get a NonUniqueResultException.
      Is this new? Our JBoss is 4.0.5-GA.
      And why can't this method just behave as expected?

      the workaround would be

       em.createQuery("SELECT Object(o) FROM MyEntity o").setMaxResult(1).getSingleResult();


      any ideas?


      martin