No result was found for query although at least one row was expected

前端 未结 1 390
太阳男子
太阳男子 2021-01-07 18:25

I have the following code:

/**
     * Search similar category given a string
     * 
     * @param $searchTerm search similar category
     */
    public fun         


        
相关标签:
1条回答
  • 2021-01-07 19:20

    You are getting this error because you are using the getSingleResult() method. it generates an Exception if it can't find even a single result. you can use the getOneOrNullResult() instead to get a NULL if there isn't any result from the query.

    Query#getSingleResult(): Retrieves a single object. If the result contains more than one object, an NonUniqueResultException is thrown. If the result contains no objects, an NoResultException is thrown. The pure/mixed distinction does not apply.

    0 讨论(0)
提交回复
热议问题