直接上代码:
Mapper.java:
/**
* 自定义添加推送消息表
* @param record
* @return 影响的条数
* @throws RuntimeException
*/
int addBroadcastRecord(Broadcast record) throws RuntimeException;
Mapper.xml:
<!-- 自定义添加推送消息表 -->
<insert id="addBroadcastRecord" parameterType="com.clou.douliu.server.bean.mybatis.Broadcast" useGeneratedKeys="true" keyProperty="id">
insert into broadcast (ID, CONTENT, START_DAY, END_DAY, TIMETAG)
values (#{id,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, #{startDay,jdbcType=TIMESTAMP}, #{endDay,jdbcType=TIMESTAMP},
#{timetag,jdbcType=TIMESTAMP})
</insert>
返回的int类型,是影响的条数, 实体bean中的id字段才是返回的数据库auto_increment 生成的Id