当前位置: 首页 > news >正文

杭州大的做网站的公司wordpress标题去重

杭州大的做网站的公司,wordpress标题去重,企业网站建设实训小结,医院网站详细设计在工程应用中#xff0c;通常会遇到多表更新操作#xff0c;在集成mybatis中需要在执行插入语句后返回主键id进行后续的表更新操作#xff0c;下面对其实现的方式记录分享出来#xff0c;以应对不同的应用场景。 1、在xml文件中应用useGeneratedKeys和keyProperty 在xml文… 在工程应用中通常会遇到多表更新操作在集成mybatis中需要在执行插入语句后返回主键id进行后续的表更新操作下面对其实现的方式记录分享出来以应对不同的应用场景。 1、在xml文件中应用useGeneratedKeys和keyProperty 在xml文件中insert标签属性中添加useGeneratedKeys和keyProperty类似如下 insert idinsert parameterTypecom.***.Attachment useGeneratedKeystrue keyPropertyattachment.id keyColumnidinsert into b_attachmenttrim prefix( suffix) suffixOverrides,if testattachment.id ! -1id,/ifif testattachment.fileName ! null and attachment.fileName !file_name,/ifif testattachment.remarks ! null and attachment.remarks !remarks,/if/trimtrim prefixvalues ( suffix) suffixOverrides,if testattachment.id ! -1#{attachment.id,jdbcTypeBIGINT},/ifif testattachment.fileName ! null and attachment.fileName !#{attachment.fileName,jdbcTypeVARCHAR},/ifif testattachment.remarks ! null and attachment.remarks !#{attachment.remarks,jdbcTypeVARCHAR},/if/trim/insert通过这种方式插入的值经常会返回1原因是因为他这里的意思是返回当前影响的行数不能准确返回你新插入的id值有时候返回的结果是准确的。 2、在xml文件中应用selectKey 在xml文件中insert标签属性中添加selectKey标签属性各个属性值含义resultType:查询结果的类型keyProperty把查询的值赋给谁order在插入前还是后执行id在insert语句插入之后才会生成id所以要在插入之后执行所以此处orderafter。类似如下 insert idinsert parameterTypecom.***.AttachmentselectKey resultTypejava.lang.Integer orderAFTER keyPropertyattachment.idselect LAST_INSERT_ID()/selectKeyinsert into b_attachmenttrim prefix( suffix) suffixOverrides,if testattachment.id ! -1id,/ifif testattachment.fileName ! null and attachment.fileName !file_name,/ifif testattachment.remarks ! null and attachment.remarks !remarks,/if/trimtrim prefixvalues ( suffix) suffixOverrides,if testattachment.id ! -1#{attachment.id,jdbcTypeBIGINT},/ifif testattachment.fileName ! null and attachment.fileName !#{attachment.fileName,jdbcTypeVARCHAR},/ifif testattachment.remarks ! null and attachment.remarks !#{attachment.remarks,jdbcTypeVARCHAR},/if/trim/insert注意keyProperty属性的值一定为对应对象的主键id否则获取不到返回的主键id。 3、注解方式 在mapper层用注解的方式用SelectKey注解里面属性含义resultType:查询结果的类型keyProperty把查询的值赋给谁 statement:查找最后一个插入的id keyColumn查询的是哪一列 before是否在插入之前执行 id在insert语句插入之后才会生成id所以要在插入之后执行所以此处beforefalse。 Insert(insert into b_attachment values(#{id},#{fileName},#{remarks}) SelectKey(statement select last_insert_id() from dual, before false, resultType Interger.class, keyColumn id, keyProperty attachment.id) int add(Param(attachment) Attachment attachment);其中“select last_insert_id()”这条语句它是配合插入语句一块只用的在insert语句执行成功后可以返回新增数据的id。 4、使用方式 在service层类似如下 ...orderMapper.insert(order);//先执行插入order的语句Integer id order.getId();//通过order.getId()获取你新插入数据的id值...
http://www.pierceye.com/news/425961/

相关文章:

  • 东莞网站建设seo公司为什么建立网站
  • 一个网站绑定多个域名可以做logo设计单子的网站
  • 哈尔滨市建设厅网站去国外做非法网站吗
  • 淮安网站建设要多少钱营销推广网歹
  • 洛阳建设企业网站成品app直播源码推荐
  • 网站值不值得做seo什么事三合一网站
  • 微网站开发协议中国建设部网站监理延续
  • 安阳网站建设公司wordpress评论模块
  • 做服装微商城网站wordpress后台载入慢
  • 免费3d模型素材网站免费发布房源的平台
  • 校园网站建设网个人网站设计论文道客巴巴
  • 网站网站制作价格建站网站建立网站第一步是什么
  • 组织部信息化建设官方网站郑州平面设计公司
  • 可信网站标志网站分析数据
  • 个人求职网站设计惠州建网站
  • 南京网站制作学校南京有名的网站建设公司
  • wordpress 代码页面宁波专业优化网站制作公司
  • 中国建设行业网站第五届中国国际进口博览会召开时间
  • 做网站设计的有些什么职位wordpress h1 h2 h3
  • 广告公司寮步网站建设哪家好怎么样在百度上推广自己的产品
  • 做亚马逊和淘宝网站公司网站建设深圳
  • 济宁建设网站网站改版 合同
  • wordpress 网站费用北京网站建设 知乎
  • 网站设计师绩效网站页面那个图怎么做
  • 帮别人起名 做ppt的网站做一个网站需要服务器吗
  • 高端网站建设公司兴田德润可以不新产品推广策划方案
  • 建设银行如何网站设置密码嵊州市建设银行网站
  • 陕西 网站建设福州mip网站建设
  • 让人做网站 需要准备什么网站建设国内外现状
  • 滨海做网站公司网页设计模板 中文