How to append a table name in MyBatis XML

134 Views Asked by At

I have XMLs for performing CRUD operations and I need to append Table names, can anyone tell me where to find the table name. Here's a sample SELECT statement

<select id = " xxxx " parameterType = "yyy" resultType = "zzz"
  select count(*)
  <include refid = " aaa"/>
</select>

Please let me know the anatomy of this sample, Like where's the name of the table.

1

There are 1 best solutions below

0
On

First create the table, for example

CREATE TABLE `resource` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `resource_name` varchar(50) NOT NULL COMMENT '文件名称',
  `resource_path` varchar(255) NOT NULL COMMENT '文件路径',
  `resource_type` varchar(50) NOT NULL COMMENT '文件类型',
  `size` bigint(20) unsigned DEFAULT NULL COMMENT '文件大小',
  `create_time` datetime NOT NULL COMMENT '上传时间',
  `create_user` varchar(20) NOT NULL COMMENT '上传者',
  `bucket_name` varchar(50) DEFAULT NULL COMMENT '存储桶',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=utf8 COMMENT='资源信息表';

Write SQL statements in xml files

    <select id="resourceType" resultType="java.lang.String">
        SELECT resource_type
        FROM `resource`
        GROUP BY resource_type
    </select>

At this point, you should know what the table name is