工作第五天日志

④ updateByPrimaryKey() 和 updateByPrimaryKeySelective()

User user =new User();
user.setId(101);
user.setUsername("joe");
user.setPassword("joe");
user.setEmail("joe@163.com");
userDAO.updateByPrimaryKey(user);
相当于:update user set username='joe',password='joe',email='joe@163.com' where id=101

User user = new User();
user.setId(101);
user.setPassword("joe");
userDAO.updateByPrimaryKeySelective(user);
相当于:
update user set password='joe' where id=101

 updateByExample() 和 updateByExampleSelective()

UserExample example = new UserExample();
Criteria criteria = example.createCriteria();
criteria.andUsernameEqualTo("joe");
User user = new User();
user.setPassword("123");
userDAO.updateByPrimaryKeySelective(user,example);

相当于:update user set password='123' where username='joe'

http://joe5456536.blog.163.com/blog/static/85374773201010273375550/


今天下午配置好一个action后,进入首页都报404,调试了好久发现ibatorConfig.xml中最好这样写:

<daoGenerator targetPackage="com.yzy.admin.dao" targetProject="yzy_b2c" type="SPRING" implementationPackage="com.yzy.admin.dao.impl" />
implementationPackage尽量也要写上。

调试结果还是不成功,最好请教别人才发现在控制台中已经有了exception报出了,结果的问题是:单词写错了,应该是xxxDAO却写成了xxxDao。恶心了一下午的问题终于解决了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值