1

I have a mybatis query that returns a Long value depending on a parameter , but if the parameter doesn´t exist on the db it returns null, but I´m getting this exception:

Mapper method 'mysqlservermethod attempted to return null from a method with a primitive return type (long).

How can I allow to return a null or what other thing can I do so, I can control in my java part for do something when the query returns null or let me know that there are no values that match the query, without doing a select count before?

MyBatys select header:

resultType="java.lang.Long" >
wty
  • 21
  • 5
  • 1
    See this [Q&A](https://stackoverflow.com/q/2254435/1261766). To receive `null`, the return type must be `java.lang.Long` instead of `long`. – ave Dec 15 '21 at 23:36
  • 1
    I already have resultType="java.lang.Long" > but doesn´t work @ave – wty Dec 17 '21 at 10:18
  • 1
    As the error message says, it's the method's return type. You should post the complete Java and XML mapper method/statement. – ave Dec 17 '21 at 10:35

0 Answers0