Alex_TD

Mybatis---注意事项及配置类属性

1.注意事项:Mapper 里字符串用""双引号,

  select * from table  where concat(col1,col2) like "%"#{col3}"%";

  select count(id) from  table;

    1.实体类的属性名和数据库字段一致

    2.绑定映射resource 必须是路径名com/xxx/xxx/xxx.XML

    3.insert  update  delete 需要提交sql会话操作的事务。

2.配置文件属性:

    1.<properties> 属性<settings>设置<typeAliases>实体类的别名  有顺序的

    2.XML中间中的& 用&amp; 替代

    3.数据库url  mysql 的写法:jdbc:mysql://localhost......

    4.Mapper resouce="com/xxx/xxx.xml")    class="com.xx.xx.xx"    package="com.xxx"    class package 要保证接口类和Mapper映射文件名一致。

 

      


posted on 2020-02-17 13:19  Alex_TD  阅读(298)  评论(0编辑  收藏  举报