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/11/10 07:17:55 UTC

[GitHub] [shardingsphere] iblilife edited a comment on issue #8108: ParameterMarkerExpressionSegment cannot be cast to class LiteralExpressionSegment

iblilife edited a comment on issue #8108:
URL: https://github.com/apache/shardingsphere/issues/8108#issuecomment-724512361


   > @iblilife您可以提供分片配置吗?我将尝试重现此问题。
   
   Mysql table
   ```sql
   CREATE TABLE `shop_message_history_0` (
     `id` bigint NOT NULL,
     `shop_id` bigint NOT NULL,
     `signin_name` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `sms_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `sms_size` int NOT NULL,
     `receive_status_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `created_date_time` datetime NOT NULL,
     `mobile` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `sms_balance_discount` int NOT NULL,
     `external_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL ,
     `failure_des` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
     PRIMARY KEY (`id`) USING BTREE
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
   
   CREATE TABLE `shop_message_history_1` (
     `id` bigint NOT NULL,
     `shop_id` bigint NOT NULL,
     `signin_name` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `sms_content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `sms_size` int NOT NULL,
     `receive_status_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `created_date_time` datetime NOT NULL,
     `mobile` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
     `sms_balance_discount` int NOT NULL,
     `external_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL ,
     `failure_des` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
     PRIMARY KEY (`id`) USING BTREE
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
   ```
   
   MyBatis Mapper.java
   ```java
   public interface ShopMessageHistoryMapper extends CoreMapper<ShopMessageHistory> {
   
       List<ShopMessageHistory> fetchShopMessageSendHistoryList(
               @Param("shopId") Long shopId, @Param("statusId") String statusId);
       
       List<ShopMessageHistory> fetchShopMessageSendHistoryList2(
               @Param("shopId") Long shopId, @Param("statusId") String statusId);
   }
   ```
   
   Mybatis Mapper.xml
   ```xml
   <!-- not work    throw error  -->
   <select id="fetchShopMessageSendHistoryList"
             resultType="com.inooyee.ss.candy.model.princess.po.ShopMessageHistory">
       SELECT *, #{statusId} as rewriteStatusId FROM shop_message_history WHERE shop_id = #{shopId}
    </select>
   
   
   <!-- working OK -->
   <select id="fetchShopMessageSendHistoryList2"
             resultType="com.inooyee.ss.candy.model.princess.po.ShopMessageHistory">
       SELECT *  FROM shop_message_history WHERE shop_id = #{shopId}
    </select>
   ```
   
    sharding configuration
   ```text
   defaultDataSourceName: princess
   tables:
     shop_message_history:
       actualDataNodes: princess.shop_message_history_$->{0..1}
       databaseStrategy:
         none: ''
       logicTable: shop_message_history
       tableStrategy:
         inline:
           algorithmExpression: shop_message_history_$->{shop_id % 2}
           shardingColumn: shop_id
   ```
   


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