Mybatis insert之后把主键返回给实体类

  
  
              select IMPORT_BOND_ORDER_SEQ.nextval as id from dual
      
    insert into TB_IMPORT_BOND_ORDER (ID, ORDER_TYPE, ORDER_NO, 
      EBP_CODE, EBP_NAME, EBC_CODE, 
      EBC_NAME, GOODS_VALUE, FREIGHT, 
      DISCOUNT, TAX_TOTAL, ACTURAL_PAID, 
      CURRENCY, BUYER_REG_NO, BUYER_NAME, 
      BUYER_ID_TYPE, BUYER_ID_NUMBER, PAY_CODE, 
      PAY_NAME, PAY_TRANSACTION_ID, BATCH_NUMBERS, 
      CONSIGNEE, CONSIGNEE_TELEPHONE, CONSIGNEE_ADDRESS, 
      CONSIGNEE_DITRICT, NOTE, APP_STATUS, 
      ACTIVE, CREATE_DATE, APP_TYPE, 
      LAST_STATUS, TRANSPORT_CODE, TRANSPORT_NAME, 
      VERSION_ID, APP_TIME, FLAG, 
      PROVINCE, CITY, AREA, 
      LOGISTICS_CODE, LOGISTICS_NAME)
    values (#{id,jdbcType=DECIMAL}, #{orderType,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, 
      #{ebpCode,jdbcType=VARCHAR}, #{ebpName,jdbcType=VARCHAR}, #{ebcCode,jdbcType=VARCHAR}, 
      #{ebcName,jdbcType=VARCHAR}, #{goodsValue,jdbcType=DECIMAL}, #{freight,jdbcType=DECIMAL}, 
      #{discount,jdbcType=DECIMAL}, #{taxTotal,jdbcType=DECIMAL}, #{acturalPaid,jdbcType=DECIMAL}, 
      #{currency,jdbcType=VARCHAR}, #{buyerRegNo,jdbcType=VARCHAR}, #{buyerName,jdbcType=VARCHAR}, 
      #{buyerIdType,jdbcType=VARCHAR}, #{buyerIdNumber,jdbcType=VARCHAR}, #{payCode,jdbcType=VARCHAR}, 
      #{payName,jdbcType=VARCHAR}, #{payTransactionId,jdbcType=VARCHAR}, #{batchNumbers,jdbcType=VARCHAR}, 
      #{consignee,jdbcType=VARCHAR}, #{consigneeTelephone,jdbcType=VARCHAR}, #{consigneeAddress,jdbcType=VARCHAR}, 
      #{consigneeDitrict,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{appStatus,jdbcType=DECIMAL}, 
      #{active,jdbcType=DECIMAL}, #{createDate,jdbcType=TIMESTAMP}, #{appType,jdbcType=DECIMAL}, 
      #{lastStatus,jdbcType=DECIMAL}, #{transportCode,jdbcType=VARCHAR}, #{transportName,jdbcType=VARCHAR}, 
      #{versionId,jdbcType=DECIMAL}, #{appTime,jdbcType=TIMESTAMP}, #{flag,jdbcType=VARCHAR}, 
      #{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR}, 
      #{logisticsCode,jdbcType=VARCHAR}, #{logisticsName,jdbcType=VARCHAR})
  


其中关键是下面这句,其中利用oracle序列当做ID存储在insert之前就给id赋值了

 
              select IMPORT_BOND_ORDER_SEQ.nextval as id from dual
    
mysql做法就没这么复杂,因为其ID实自增长的 只需要
 
  

你可能感兴趣的:(Mybatis insert之后把主键返回给实体类)