首页
学习
活动
专区
圈层
工具
发布

org.apache.ibatis.binding.BindingException: Mapper method attempted to return null from a method wi

null from a method with a primitive return type (long)....当在数据库中查询没有查到这条记录,注意这里是根本没有这条记录,所以当然也不会返回id,对于这种情况Mybatis框架返回结果是null @Select("select id from user where...当然是不可以的 Long a = null; long b = a; 因为会报java.lang.NullPointerException,而框架报出来的就是attempted to return null...) { return 0; } return userId; } 方案二:对于可以查询到记录的,只是在该记录中你需要的字段是null这种情况下,除了上述方法,还可以通过修改sql来解决。...select ifnull(id,0) from user where name = 'test' and status = 1; select case id when null then 0 end

66410
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Sqlite数据库使用---基础研究

    目录 Sqlite简介 Sqlite创建表语句 Sqlite增加insert语句 Sqlite查询表select Sqlite更新数据update 表排序order by 查询某段数据limit和offset...1sqlite> .schema worker 2CREATE TABLE worker 3 (id int primary key not null, 4 name text not null...’,1); 2sqlite> 看一下表中是否有数据 1sqlite> select * from worker; 21|fanfan|27|HeNan| 3sqlite> 这样的打印格式看起来不太舒服...执行两个命令 .header on:用于显示出列名 .mode column:用于制表 效果如下所示 1sqlite> .header on --显示列名 2sqlite> select * from...:select * from table_name;因为对列的展示不做要求,所以按照默认创建表格时的列进行横向显示 在insert中已经演示过查询所有列了 1sqlite> select * from

    1.7K00
    领券