您的位置:首页 > 其它

mybatis 插入数据获取当条数据的id

2016-04-08 11:50 417 查看
@Insert("INSERT INTO m_sales_promotion (name,start_time,end_time,type,status)  VALUES "

+"(#{name},#{startTime},#{endTime},#{type},#{status})")
@Options(useGeneratedKeys=true,keyProperty="promotionId")
int addPromotion(Promotion pn);

@Options(useGeneratedKeys=true,keyProperty="promotionId") 设置好主键后,  执行该sql就可以拿到主键 promotionId,可以到对象promotion中获取到promotionId
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mybatis