实体类
public class GenTable extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private Long tableId;
/** 表名称 */
@NotBlank(message = "表名称不能为空")
private String tableName;
/** 表列信息 */
@Valid
private List<GenTableColumn> columns;
}
xml
<resultMap type="GenTable" id="GenTableResult">
<id property="tableId" column="table_id" />
<result property="tableName" column="table_name" />
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
</resultMap>
<resultMap type="GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id" />
<result property="tableId" column="table_id" />
<result property="columnName" column="column_name" />
</resultMap>
<select id="selectGenTableByName" resultMap="GenTableResult">
SELECT t.table_id, t.table_name,c.column_id, c.column_name
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
</select>
~~~