I have the following code:
/**
* Search similar category given a string
*
* @param $searchTerm search similar category
*/
public fun
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.