用selectKey获取id值为负数
来源:互联网 发布:淘宝洗纹身精油骗局 编辑:程序博客网 时间:2024/05/22 14:32
项目用的是oracle结合mybatise,可能是受Mysql的影响过深,我在上层(contoller层)获取用这种方式
select
nvl(max(ID)+1,1) from EDSP_CLIENT_KEY_CODE
生成的id时都用了这样的方式:
int id=edspClientKeyCodeService.newUpdateOrAdd(company);
这是不对的!!!这个返回值是个负数,不是真正的id值
正确的方式!!!log.info(“保存的id值为:”+company.getId());
要通过Object.getId()的方式去获取!!!!!!2次了555~~~~
补充一点即使在dao中返回的值是void还是能通过对像获取id值
@Override
public void newUpdateOrAdd(EdspClientKeyCode clientKeyCode) {
EdspClientKeyCode obj=getSqlSession().selectOne(“EdspClientKeyCodeMapper.getCompanyById”,clientKeyCode.getId());
if(obj==null){
//新增
getSqlSession().insert(“EdspClientKeyCodeMapper.insertSelective”, clientKeyCode);
}else{
//更新
getSqlSession().update(“EdspClientKeyCodeMapper.updateSelective”, clientKeyCode);
}
}
- 用selectKey获取id值为负数
- spring+mybatis selectKey获取不到最后一个插入的ID
- Ibatis selectKey 返回值为空
- SelectKey查询id
- pthread_t 线程id为负数的原因
- 颜色值为负数
- mybatis selectkey获取主键
- mybatis 获取更新(update)记录的id 之< selectKey > 用法
- spring mybatis insert selectkey 获取不到主键值
- 用TRANSLATE查找文本值为负数的行
- SelectKey
- selectKey
- selectKey
- 用ibatis selectKey 返回自动生成的主键值
- 关于binarySearch返回值为负数
- Android fragment 获取id,findViewById为空
- ibatis 的selectKey 实现插入数据后获得id
- mybatis入门使用3:selectKey返回最近插入的id
- Android中手势识别检测器GestureDetector
- cherry-pick 主线commit 并修改commit log
- python---urllib2使用
- HTML5代码规范
- js 中奖几率计算!
- 用selectKey获取id值为负数
- 请实现这两个变量数值的交换(比如int a = 10,int b = 20变成int a = 20,int b = 10),要求写3种或3种以上的实现方式
- java 对月份的加减方法
- 恒德可视化指挥调度解决方案
- jsp中的指令标识
- Servle的线程安全问题
- 简易printf打印实现,占用内存非常小------<嵌入式开发自学笔记>
- IDEA 反撤销(还原)快捷键及新版IDEA使用教程
- Android8.0 ZenMode 静音模式