当然这个文件中没有任何的元素
The Mapper XML files have only a few first class elements :
cache – Configuration of the cache for a given namespace. cache-ref – Reference to a cache configuration from another namespace. resultMap – The most complicated and powerful element that describes how to load your objects from the database result sets. sql – A reusable chunk of SQL that can be referenced by other statements. insert – A mapped INSERT statement. update – A mapped UPDATE statement. delete – A mapped DELETE statement. select – A mapped SELECT statement.select
简单的例子:
select也有很多属性可以让你配置:
insert, update and delete
语句:
f your database supports auto-generated key fields (e.g. MySQL and SQL Server),上面的插入语句可以写成:
如果你的数据库还支持多条记录插入,可以使用下面这个语句:
sql
这个element可以定义一些sql代码的碎片,然后在多个语句中使用,降低耦合。比如:
然后在下面的语句中使用:
Result Maps
官网给了个最最复杂的例子
大体意思呢就是一个博客系统有一个作者,很多博文,博文中有一个作者,很多评论,很多标签(包括了一对多,一对一)
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!