mybatis映射XML文件详解及实例

mybatis映射XML文件

一个简单的映射文件:





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

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

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

select

简单的例子:

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


 select
  ,
  
 from some_table t1
  cross join some_table t2

Result Maps

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

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






 
  
 
 
 
  
  
  
  
  
  
 
 
  
  
  
  
   
  
  
   
  
  
   
  
 


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

你可能感兴趣的:(mybatis映射XML文件详解及实例)