您现在的位置是:网站首页> 编程资料编程资料

mybatis映射XML文件详解及实例_数据库其它_

2023-05-27 416人已围观

简介 mybatis映射XML文件详解及实例_数据库其它_

mybatis映射XML文件

一个简单的映射文件:

当然这个文件中没有任何的元素

The Mapper XML files have only a few first class elements :

  1. cache – Configuration of the cache for a given namespace.
  2. cache-ref – Reference to a cache configuration from another namespace.
  3. resultMap – The most complicated and powerful element that describes how to load your objects from the database result sets.
  4. sql – A reusable chunk of SQL that can be referenced by other statements.
  5. insert – A mapped INSERT statement.
  6. update – A mapped UPDATE statement.
  7. delete – A mapped DELETE statement.
  8. select – A mapped SELECT statement.

select

简单的例子:

select也有很多属性可以让你配置:

 select ,  from some_table t1 cross join some_table t2 

Result Maps

官网给了个最最复杂的例子

大体意思呢就是一个博客系统有一个作者,很多博文,博文中有一个作者,很多评论,很多标签(包括了一对多,一对一)

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

-六神源码网