Home >Database >Mysql Tutorial >Mybatis 插入数据,返回自增长的id
Mybatis插入数据,返回自增长的id 无 insert id="insert" parameterType="Spares" useGeneratedKeys="true" keyProperty="id"insert into spares(spares_id,spares_name,spares_type_id,spares_spec)values(#{id},#{name},#{typeId},#{spec})/insert sparesDa
Mybatis 插入数据,返回自增长的id<insert id="insert" parameterType="Spares" useGeneratedKeys="true" keyProperty="id"> insert into spares(spares_id,spares_name,spares_type_id,spares_spec) values(#{id},#{name},#{typeId},#{spec}) </insert>
sparesDao.insert(spares); //插入 spares.getId();//取得主键id