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 2020/06/01 10:42:54 UTC

[GitHub] [shardingsphere-example] ljz0721cx opened a new issue #211: Sharding value must implements Comparable.

ljz0721cx opened a new issue #211:
URL: https://github.com/apache/shardingsphere-example/issues/211


   ## Bug Report
   
   
   
   ### Which version of ShardingSphere did you use?
    <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
               <version>4.1.0</version>
           </dependency>
   
           <!-- for spring namespace -->
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-namespace</artifactId>
               <version>4.1.0</version>
           </dependency>
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC 
   ### Expected behavior
   SNOWFLAKE config can use
   ### Actual behavior
    Cause: java.lang.IllegalArgumentException: Sharding value must implements Comparable.
   ### Reason analyze (If you can)
   when insert can not bind genrate sharding value
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   
   sharding:
         tables:
           t_order:
             key-generator:
               column: order_no
               type: SNOWFLAKE
             actual-data-nodes: ds-$->{2019..2020}.t_order$->{0..1}
             database-strategy:
               standard:
                 sharding-column: create_date
                 precise-algorithm-class-name: com.bule.spring.dao.sharding.TimeDatabaseShardingAlgorithm
             table-strategy:
               inline:
                 sharding-column: order_no
                 algorithm-expression: t_order$->{order_no % 2}
   
   
       <resultMap id="BaseResultMap" type="com.bule.spring.domain.Order">
           <id column="order_no" property="orderNo"/>
           <result column="order_id"  property="orderId"/>
           <result column="user_id" property="userId"/>
           <result column="status" property="status"/>
           <result column="create_date" property="createDate"/>
       </resultMap>
   
   
       <insert id="insert" parameterType="com.bule.spring.domain.Order" >
           INSERT INTO t_order (
              order_id,order_no, user_id, status,create_date
           )
           VALUES (
               #{orderId,jdbcType=INTEGER},
               #{orderNo,jdbcType=BIGINT},
               #{userId,jdbcType=INTEGER},
               #{status,jdbcType=INTEGER},
               #{createDate,jdbcType=TIMESTAMP}
           )
       </insert>
   
   
   
    @Test
       public void testInsert() {
           for (int i = 0; i < 10; i++) {
               Order order = new Order();
               order.setOrderId(Long.valueOf(i));
               order.setUserId(20001);
               order.setStatus("insert");
               order.setCreateDate(DateUtils.addYears(new Date(),-1));
              // order.setOrderNo(IdWorker.getId());
               orderShardingMapper.insert(order);
           }
           for (int i = 0; i < 10; i++) {
               Order order = new Order();
               order.setOrderId(Long.valueOf(i));
               order.setUserId(20001);
               order.setStatus("insert");
               order.setCreateDate(new Date());
               //order.setOrderNo(IdWorker.getId());
               orderShardingMapper.insert(order);
           }
       }
   
   
   


----------------------------------------------------------------
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