④ updateByPrimaryKey() 和 updateByPrimaryKeySelective()
User user =new User();
user.setId(101);
user.setUsername("joe");
user.setPassword("joe");
user.setEmail("[email protected]");
userDAO.updateByPrimaryKey(user);
相当于:update user set username='joe',password='joe',email='[email protected]' 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。恶心了一下午的问题终于解决了。