<update id="addTableByGroundStation" parameterType="String">
CREATE TABLE ${tableName}
(
flowmet_id int(10) unsigned NOT NULL AUTO_INCREMENT,
sat_id int(20) DEFAULT NULL,
ground_station_id int(20) DEFAULT NULL,
telemetry_data text DEFAULT NULL,
times datetime DEFAULT NULL,
PRIMARY KEY (flowmet_id)
)
ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8;
</update>
不然会报错 There is no getter for property named ‘tableName’ in ‘class java.lang.String’
(3)原因:
Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.tableName值,引起报错。
(4)解决办法:
再dao层接口中给相应的方法加上参数说明, ${tableName} 传过来的时候一定要注意在Mapper 用使用@Param("tableName")
详情见:https://blog.youkuaiyun.com/edison_03/article/details/77163792
<mapper namespace="fc.com.mapper.HistoricalDataMapper">
<resultMap id="TelemetryAndInstructDateMap" type="fc.com.pojo.TelemetryAndInstructDate">
<collection property="instruct" resultMap="instructMap"/>
<collection property="telemetry" resultMap="telemetryMap"/>
</resultMap>
<resultMap id="instruct" type="fc.com.pojo.InstructFlowment">
<id column="_instruct_id" property="instructId" jdbcType="INTEGER" />
<result column="sat_id" property="satId" jdbcType="INTEGER" />
<result column="ground_station_id" property="groundStationId" jdbcType="INTEGER" />
<result column="instruct_data" property="instructData" jdbcType="VARCHAR" />
<result column="_datetime" property="time" jdbcType="TIMESTAMP" />
</resultMap>
<resultMap id="telemetry" type="fc.com.pojo.TelemetryFlowment">
<id column="flowmet_id" property="flowmentId" jdbcType="INTEGER" />
<result column="sat_id" property="satId" jdbcType="INTEGER" />
<result column="ground_station_id" property="groundStationId" jdbcType="INTEGER" />
<result column="telemetry_data" property="telemetryData" jdbcType="VARCHAR" />
<result column="_datetime" property="times" jdbcType="TIMESTAMP" />
</resultMap>
<!-- Mybatis 包含List属性 第二种写法
<resultMap type="fc.com.pojo.TelemetryAndInstructDate" id="TelemetryAndInstructDateMap"> -->
<!-- association字面意思关联,这里只专门做一对一关联; property表示是com.mybatis.bean.StudentTemp中的属性名称;
javaType表示该属性是什么类型对象 -->
<!-- property 表示com.mybatis.bean.Class中的属性; column 表示表中的列名 -->
<!-- property表示集合类型属性名称,ofType表示集合中的对象是什么类型 -->
<!-- <collection property="telemetry" ofType="fc.com.pojo.TelemetryFlowment"/>
<id column="flowmet_id" property="flowmentId" jdbcType="INTEGER" />
<result column="sat_id" property="satId" jdbcType="INTEGER" />
<result column="ground_station_id" property="groundStationId" jdbcType="INTEGER" />
<result column="telemetry_data" property="telemetryData" jdbcType="VARCHAR" />
<result column="times" property="times" jdbcType="TIMESTAMP" />
</collection>
<collection property="instruct" ofType="fc.com.pojo.InstructFlowment"/>
<id column="_instruct_id" property="instructId" jdbcType="INTEGER" />
<result column="sat_id" property="satId" jdbcType="INTEGER" />
<result column="ground_station_id" property="groundStationId" jdbcType="INTEGER" />
<result column="instruct_data" property="instructData" jdbcType="VARCHAR" />
<result column="_datetime" property="time" jdbcType="TIMESTAMP" />
</collection>
</resultMap>
-->
在mysql中添加 UUID :Mysql 中动态添加 UUID