You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/09/23 08:31:36 UTC

[GitHub] [incubator-shardingsphere-example] hanxuewen opened a new issue #181: 主键赋值错误,或者未赋值

hanxuewen opened a new issue #181: 主键赋值错误,或者未赋值
URL: https://github.com/apache/incubator-shardingsphere-example/issues/181
 
 
   spring-datasource配置:
   `<bean:properties id="properties">
           <prop key="worker.id">123</prop>
           <prop key="max.tolerate.time.difference.milliseconds">10</prop>
       </bean:properties>
       
   	<sharding:key-generator id="orderKeyGenerator" type="SNOWFLAKE" column="id" props-ref="properties"/>
       <sharding:key-generator id="itemKeyGenerator" type="SNOWFLAKE" column="id" props-ref="properties"/>
       
       <sharding:data-source id="shardingDataSource">
           <sharding:sharding-rule data-source-names="dataSource">
               <sharding:table-rules>
                   <sharding:table-rule logic-table="ec_order" 
                   	actual-data-nodes="${sharding.jdbc.datasource.actual.data.nodes.order}"
                   	 table-strategy-ref="tableShardingStrategy"
                   	  key-generator-ref="orderKeyGenerator" />
                   	  
                   <sharding:table-rule logic-table="ec_order_detail" 
                   	actual-data-nodes="${sharding.jdbc.datasource.actual.data.nodes.orderitem}" 
                   	table-strategy-ref="orderDetailShardingStrategy" 
                   	key-generator-ref="itemKeyGenerator" />
               </sharding:table-rules>
           </sharding:sharding-rule>
       </sharding:data-source>`
   
   Mybaits:
   `<insert id="insert" parameterType="com.dongao.phoenix.ec.shop.manage.po.OrderPo">
      <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
   	 		SELECT LAST_INSERT_ID()	
   	</selectKey>
       insert into ec_order (order_no, member_id, member_name, 
         source, order_type, order_total_price, 
         actually_pay_price, goods_total_price, freight_price, 
         activity_price, is_use_coupon, is_invoice, 
         order_status, pay_status, is_split, 
         user_remark, order_remark, is_admin_order, 
         order_time, pay_time, return_type, 
         payment, ip_address, is_logistic
         )
       values (#{orderNo,jdbcType=VARCHAR}, #{memberId,jdbcType=BIGINT}, #{memberName,jdbcType=VARCHAR}, 
         #{source,jdbcType=VARCHAR}, #{orderType,jdbcType=INTEGER}, #{orderTotalPrice,jdbcType=DOUBLE}, 
         #{actuallyPayPrice,jdbcType=DOUBLE}, #{goodsTotalPrice,jdbcType=DOUBLE}, #{freightPrice,jdbcType=DOUBLE}, 
         #{activityPrice,jdbcType=DOUBLE}, #{isUseCoupon,jdbcType=INTEGER}, #{isInvoice,jdbcType=INTEGER}, 
         #{orderStatus,jdbcType=INTEGER}, #{payStatus,jdbcType=INTEGER}, #{isSplit,jdbcType=INTEGER}, 
         #{userRemark,jdbcType=VARCHAR}, #{orderRemark,jdbcType=VARCHAR}, #{isAdminOrder,jdbcType=INTEGER}, 
         #{orderTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, #{returnType,jdbcType=INTEGER}, 
         #{payment,jdbcType=INTEGER}, #{ipAddress,jdbcType=VARCHAR}, #{isLogistic,jdbcType=INTEGER}
         )
     </insert>`
   
   
   
   没有自动追加ID,但是却把ID赋值到了别的字段:is_admin_order了
   
   但是如果我把mybaits的insert  SQL追加上ID,就不会赋值错误,但是ID也没有值,插入导数据库用的是mysql的自增值
   
   这个问题该如何处理

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services