File tree 1 file changed +15
-7
lines changed
1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -192,18 +192,26 @@ SELECT * FROM TABLE_NAME WHERE name = ?
192
192
2 . 当参数的func返回非nil的错误,则回滚
193
193
3 . 当参数的func内抛出panic,则回滚
194
194
195
- ### 7、xml
195
+ ### 7、扫描mapper文件
196
+ ```
197
+ err := gobatis.ScanMapperFile(${MAPPER_FILE_DIR})
198
+ if err != nil {
199
+ t.Fatal(err)
200
+ }
201
+ ```
202
+
203
+ ### 8、xml
196
204
197
205
gobatis支持xml的sql解析及动态sql
198
206
199
- 1 . 注册xml
207
+ 1 . 直接注册xml
200
208
201
209
```
202
210
gobatis.RegisterMapperData([]byte(main_xml))
203
211
```
204
212
205
213
或
206
-
214
+
207
215
```
208
216
gobatis.RegisterMapperFile(filePath)
209
217
```
@@ -282,11 +290,11 @@ xml数据或文件注册之后,session参数sqlid与xml action对应关系为
282
290
sess.Select("test.selectTestTable").Param(model).Result(&dataList)
283
291
```
284
292
285
- ### 8 、template
293
+ ### 9 、template
286
294
287
295
gobatis也支持go template的sql解析及动态sql
288
296
289
- 1 . 注册template
297
+ 1 . 直接注册template
290
298
291
299
```
292
300
gobatis.RegisterTemplateData([]byte(main_xml))
@@ -349,11 +357,11 @@ template数据或文件注册之后,session参数sql id与模板对应关系
349
357
sess.Select("test.selectTestTable").Param(model).Result(&dataList)
350
358
```
351
359
352
- ### 9 、gobatis-cmd生成文件使用示例
360
+ ### 10 、gobatis-cmd生成文件使用示例
353
361
354
362
参考[ cmd_test] ( https://github.com/xfali/gobatis/tree/master/test/cmd )
355
363
356
- ### 10 、 SQL语句构建器
364
+ ### 11 、 SQL语句构建器
357
365
358
366
gobatis xml特性有非常强大的动态SQL生成方案,当需要在代码中嵌入SQL语句时,也可使用SQL语句构建器:
359
367
```
You can’t perform that action at this time.
0 commit comments