- 数据库中Longint对应java中long类型
- Byte数类型先转Integer,比较好处理,每次重新generator都要记得改
- mybatis generator多次使用容易重复创建,删掉xml文件重新generator即可
- controller层一般做不侵入业务逻辑的工作,一般是入口,不能相互调用。因此对于涉及到几张表操作的一个功能,例如用户注册要在user、role、relationship中添加数据,则统一在service层完成,service可用互相调用
在try catch中try中有return不算报错
若是try-catch-finally
如try{
return 20
} cathch{}
fianlly{println 1}
会打印:
1
20
生成的文件如下
生成的xml文件若在recourse里面会出现no bounding的错误,即userMapper找不到生成的xml文件。在网上找了很多办法试过都没有用,最后只能把xml文件和userMapper放在同一路径下才行
报 Result Maps collection already contains的错误应该是generator生成的xml文件生成重复了,删除掉重新generator即可
具体用法@Override
public User loginValidation(String accountName,String userPassword) {
//System.out.println(userMapper.selectByExample());
UserExample example = new UserExample();
example.createCriteria().andUserAccountNameEqualTo(accountName).andUserPasswordEqualTo(userPassword);
List userList = userMapper.selectByExample(example);
return userList.get(0);
}
以上这条等等价于 select * from user where userAccountName=“accountName” and userPassword=“userPassword”
返回值类型是List
关于Criteria:我的理解是相当于where关键字,Criteria包含一个Cretiron的集合,每一个Criteria对象内包含的Cretiron之间是由AND连接的,是逻辑与的关系



