影落离风

The shadow falls away from the wind

0%

使用sharding-jdbc进行分表问题记录

  1. 使用sharding-jdbc-spring-boot-starter4.0.0-RC1,不支持批量插入或更新

    1
    2
    3
    4
    5
    <dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
    <version>4.0.0-RC1</version>
    </dependency>

    报错如下

    1
    2
    3
    4
    5
    6
    7
    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
    ### Error updating database. Cause: org.apache.shardingsphere.core.parse.old.parser.exception.SQLParsingException: INSERT INTO .... ON DUPLICATE KEY UPDATE can not support on sharding column, token is 'IDENTIFIER', literals is 'org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.column.ColumnSegment@6cfc536a'.
    ### The error may exist in file [D:\work\hhmt_project\delivery-adx\target\classes\mapper\HhAdxMediaKeywordSummaryMapper.xml]
    ### The error may involve defaultParameterMap
    ### The error occurred while setting parameters
    ### SQL: insert into hh_adx_media_keyword_summary(media_id, key_word, key_num, dimension_time, create_time, update_time, description) values (?, ?, ?, ?, ?, now(), ?) on duplicate key update media_id = values(media_id), key_word = values(key_word), key_num = values(key_num), dimension_time = values(dimension_time), create_time = values(create_time), update_time = values(update_time), description = values(description)
    ### Cause: org.apache.shardingsphere.core.parse.old.parser.exception.SQLParsingException: INSERT INTO .... ON DUPLICATE KEY UPDATE can not support on sharding column, token is 'IDENTIFIER', literals is 'org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.column.ColumnSegment@6cfc536a'.
  2. 使用shardingsphere-jdbc-core-spring-boot-starter,不支持批量插入或更新

    1
    2
    3
    4
    5
    <dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
    <version>5.2.1</version>
    </dependency>

    报错如下

    1
    2
    3
    4
    5
    6
    7
    8
    org.springframework.jdbc.UncategorizedSQLException: 
    ### Error updating database. Cause: java.sql.SQLException: Unknown exception: Insert statement does not support sharding table routing to multiple data nodes.
    ### The error may exist in file [D:\work\my_project\shardingsphere-jdbc-demo\target\classes\mapper\TOrderMapper.xml]
    ### The error may involve defaultParameterMap
    ### The error occurred while setting parameters
    ### SQL: insert into t_order(name, user_id, create_time) values (?, ?, ?) on duplicate key update name = values(name), user_id = values(user_id), create_time = values(create_time)
    ### Cause: java.sql.SQLException: Unknown exception: Insert statement does not support sharding table routing to multiple data nodes.
    ; uncategorized SQLException; SQL state [HY000]; error code [30000]; Unknown exception: Insert statement does not support sharding table routing to multiple data nodes.; nested exception is java.sql.SQLException: Unknown exception: Insert statement does not support sharding table routing to multiple data nodes.

暂时没有解决方案