1.The version of shardingsphere I use is 4.0.0-RC1, and the version of MySQL 
connector Java driven  is 5.1.4
The error log is as follows:


[2019-12-05 09:34:12] DEBUG 
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver(http-nio-8088-exec-10);
 :Resolving exception from handler [public net.sf.json.JSONObject 
com.jd.bdp.cv.web.controller.CvTaskController.save(com.jd.bdp.cv.domain.CvUser,com.jd.bdp.cv.domain.CvTask,org.springframework.web.multipart.MultipartFile,javax.servlet.http.HttpServletRequest)
 throws java.lang.Exception]: 
org.springframework.dao.DataIntegrityViolationException: ### Error updating 
database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect 
datetime value: 'now()' for column 'created' at row 1 ### The error may involve 
com.jd.bdp.cv.dao.CvTaskDao.save-Inline ### The error occurred while setting 
parameters ### SQL: INSERT INTO cv_task ( team_id, `name`, `type`, sample_num, 
status, sample_mark_user_pins, owner, file_type, audit_type, audit_pins, 
sample_per_task, amount_per_task, fault_rate, remarks, creator, created, 
modifier, modified, deleted, point_num, extend, file_dir_ids, free_dept_name, 
free_dept_id, plat_form_type, jifen,jifen_type, task_budget, need_audit, 
create_erp, related_task_id, parent_task_id, is_operate, distribute_number, 
iou, dept_name, item_name, item_id, disk_name) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, now(), ?, now(), 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?) ### Cause: com.mysql.jdbc.MysqlDataTruncation: Data 
truncation: Incorrect datetime value: 'now()' for column 'created' at row 1 ; 
SQL []; Data truncation: Incorrect datetime value: 'now()' for column 'created' 
at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data 
truncation: Incorrect datetime value: 'now()' for column 'created' at row 1 
[2019-12-05 09:34:12] DEBUG 
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver(http-nio-8088-exec-10);
 :Resolving exception from handler [public net.sf.json.JSONObject 
com.jd.bdp.cv.web.controller.CvTaskController.save(com.jd.bdp.cv.domain.CvUser,com.jd.bdp.cv.domain.CvTask,org.springframework.web.multipart.MultipartFile,javax.servlet.http.HttpServletRequest)
 throws java.lang.Exception]: 
org.springframework.dao.DataIntegrityViolationException: ### Error updating 
database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect 
datetime value: 'now()' for column 'created' at row 1 ### The error may involve 
com.jd.bdp.cv.dao.CvTaskDao.save-Inline ### The error occurred while setting 
parameters ### SQL: INSERT INTO cv_task ( team_id, `name`, `type`, sample_num, 
status, sample_mark_user_pins, owner, file_type, audit_type, audit_pins, 
sample_per_task, amount_per_task, fault_rate, remarks, creator, created, 
modifier, modified, deleted, point_num, extend, file_dir_ids, free_dept_name, 
free_dept_id, plat_form_type, jifen,jifen_type, task_budget, need_audit, 
create_erp, related_task_id, parent_task_id, is_operate, distribute_number, 
iou, dept_name, item_name, item_id, disk_name) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, now(), ?, now(), 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?) ### Cause: com.mysql.jdbc.MysqlDataTruncation: Data 
truncation: Incorrect datetime value: 'now()' for column 'created' at row 1 ; 
SQL []; Data truncation: Incorrect datetime value: 'now()' for column 'created' 
at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data 
truncation: Incorrect datetime value: 'now()' for column 'created' at row 1 
[2019-12-05 09:34:12] DEBUG 
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver(http-nio-8088-exec-10);
 :Invoking @ExceptionHandler method: public void 
com.jd.bdp.cv.web.controller.ExceptionHandleController.page500(java.lang.Exception,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
 throws java.lang.Exception [2019-12-05 09:34:12] DEBUG 
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver(http-nio-8088-exec-10);
 :Invoking @ExceptionHandler method: public void 
com.jd.bdp.cv.web.controller.ExceptionHandleController.page500(java.lang.Exception,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
 throws java.lang.Exception [2019-12-05 09:34:12] ERROR 
com.jd.bdp.cv.web.controller.SqlController(http-nio-8088-exec-10); :系统错误 
org.springframework.dao.DataIntegrityViolationException: ### Error updating 
database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect 
datetime value: 'now()' for column 'created' at row 1 ### The error may involve 
com.jd.bdp.cv.dao.CvTaskDao.save-Inline ### The error occurred while setting 
parameters ### SQL: INSERT INTO cv_task ( team_id, `name`, `type`, sample_num, 
status, sample_mark_user_pins, owner, file_type, audit_type, audit_pins, 
sample_per_task, amount_per_task, fault_rate, remarks, creator, created, 
modifier, modified, deleted, point_num, extend, file_dir_ids, free_dept_name, 
free_dept_id, plat_form_type, jifen,jifen_type, task_budget, need_audit, 
create_erp, related_task_id, parent_task_id, is_operate, distribute_number, 
iou, dept_name, item_name, item_id, disk_name) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, now(), ?, now(), 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?) ### Cause: com.mysql.jdbc.MysqlDataTruncation: Data 
truncation: Incorrect datetime value: 'now()' for column 'created' at row 1 ; 
SQL []; Data truncation: Incorrect datetime value: 'now()' for column 'created' 
at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data 
truncation: Incorrect datetime value: 'now()' for column 'created' at row 1 at 
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101)
 at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
 at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
 at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
 at 
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
 at 
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:368)
 at com.sun.proxy.$Proxy18.insert(Unknown Source) at 
org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240) at 
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:46) at 
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) at 
com.sun.proxy.$Proxy36.save(Unknown Source) at 
com.jd.bdp.cv.service.impl.CvTaskServiceImpl.saveTask(CvTaskServiceImpl.java:246)
 at 
com.jd.bdp.cv.service.impl.CvTaskServiceImpl$$FastClassByCGLIB$$b24d251c.invoke(<generated>)
 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at 
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
 at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
 at 
org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
 at 
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
 at 
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
 at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 at 
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
 at 
com.jd.bdp.cv.service.impl.CvTaskServiceImpl$$EnhancerByCGLIB$$fa2c619b.saveTask(<generated>)
 at 
com.jd.bdp.cv.web.controller.CvTaskController.saveCvTask(CvTaskController.java:514)
 at 
com.jd.bdp.cv.web.controller.CvTaskController.save(CvTaskController.java:360) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497) at 
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
 at 
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
 at 
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
 at 
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
 at 
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
 at 
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
 at 
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
 at 
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
 at 
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
 at 
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) at 
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at 
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at 
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
 at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
 at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
 at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 
at 
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
 at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) 
at 
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
 at 
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
 at 
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
 at 
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at 
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Thread.java:745) Caused by: 
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: 
'now()' for column 'created' at row 1 at 
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3374) at 
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308) at 
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837) at 
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961) at 
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543) at 
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737) 
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998) at 
com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931)
 at 
com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
 at 
com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
 at 
com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:118)
 at 
com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
 at 
org.apache.shardingsphere.shardingjdbc.executor.SQLExecuteCallbackFactory$2.executeSQL(SQLExecuteCallbackFactory.java:65)
 at 
org.apache.shardingsphere.shardingjdbc.executor.SQLExecuteCallbackFactory$2.executeSQL(SQLExecuteCallbackFactory.java:61)
 at 
org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteCallback.execute0(SQLExecuteCallback.java:69)
 at 
org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteCallback.execute(SQLExecuteCallback.java:58)
 at 
org.apache.shardingsphere.core.execute.ShardingExecuteEngine.syncGroupExecute(ShardingExecuteEngine.java:126)
 at 
org.apache.shardingsphere.core.execute.ShardingExecuteEngine.serialExecute(ShardingExecuteEngine.java:91)
 at 
org.apache.shardingsphere.core.execute.ShardingExecuteEngine.groupExecute(ShardingExecuteEngine.java:83)
 at 
org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteTemplate.executeGroup(SQLExecuteTemplate.java:73)
 at 
org.apache.shardingsphere.core.execute.sql.execute.SQLExecuteTemplate.executeGroup(SQLExecuteTemplate.java:56)
 at 
org.apache.shardingsphere.shardingjdbc.executor.AbstractStatementExecutor.executeCallback(AbstractStatementExecutor.java:128)
 at 
org.apache.shardingsphere.shardingjdbc.executor.PreparedStatementExecutor.execute(PreparedStatementExecutor.java:156)
 at 
org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:172)
 at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source) at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497) at 
org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:55)
 at com.sun.proxy.$Proxy27.execute(Unknown Source) at 
org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
 at 
org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
 at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45) 
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100) at 
org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75) at 
org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
 at 
org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497) at 
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
 ... 61 more
2.   sql.show:


reating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@b2b8f7] was 
not registered for synchronization because synchronization is not active
JDBC Connection 
[org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.ShardingConnection@181b5b3]
 will not be managed by Spring
ooo Using Connection 
[org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.ShardingConnection@181b5b3]
==>  Preparing: SELECT count(u.id) FROM cv_user_task u LEFT JOIN cv_task t on 
t.id = u.task_id where u.deleted = 0 AND u.team_id = ? and t.audit_type != 5 
==> Parameters: 122(Long)
[2019-12-05 09:39:30] INFO  ShardingSphere-SQL(http-nio-8088-exec-2); :Rule 
Type: sharding
[2019-12-05 09:39:30] INFO  ShardingSphere-SQL(http-nio-8088-exec-2); :Logic 
SQL: SELECT count(u.id)
        FROM cv_user_task u
        LEFT JOIN cv_task t on t.id = u.task_id
        where u.deleted = 0
        AND u.team_id = ?
         
         
         
         
         
         
            and t.audit_type != 5
[2019-12-05 09:39:30] INFO  ShardingSphere-SQL(http-nio-8088-exec-2); 
:SQLStatement: 
SelectStatement(super=DQLStatement(super=AbstractSQLStatement(type=DQL, 
tables=Tables(tables=[Table(name=cv_user_task, alias=Optional.of(u)), 
Table(name=cv_task, alias=Optional.of(t))]), 
routeConditions=Conditions(orCondition=OrCondition(andConditions=[])), 
encryptConditions=Conditions(orCondition=OrCondition(andConditions=[])), 
sqlTokens=[TableToken(tableName=cv_user_task, quoteCharacter=NONE, 
schemaNameLength=0), TableToken(tableName=cv_task, quoteCharacter=NONE, 
schemaNameLength=0)], parametersIndex=1, logicSQL=SELECT count(u.id)
        FROM cv_user_task u
        LEFT JOIN cv_task t on t.id = u.task_id
        where u.deleted = 0
        AND u.team_id = ?
         
         
         
         
         
         
            and t.audit_type != 5)), containStar=false, 
firstSelectItemStartIndex=7, selectListStopIndex=17, groupByLastIndex=0, 
items=[AggregationSelectItem(type=COUNT, innerExpression=(u.id), 
alias=Optional.absent(), derivedAggregationSelectItems=[], index=1)], 
groupByItems=[], orderByItems=[], limit=null, subqueryStatement=null, 
subqueryStatements=[], subqueryConditions=[])
[2019-12-05 09:39:30] INFO  ShardingSphere-SQL(http-nio-8088-exec-2); :Actual 
SQL: cv_dataSource ::: SELECT count(u.id)
        FROM cv_user_task_0 u
        LEFT JOIN cv_task t on t.id = u.task_id
        where u.deleted = 0
        AND u.team_id = ?
         
         
         
         
         
         
            and t.audit_type != 5 ::: [122]
[2019-12-05 09:39:30] INFO  ShardingSphere-SQL(http-nio-8088-exec-2); :Actual 
SQL: cv_dataSource ::: SELECT count(u.id)
        FROM cv_user_task_1 u
        LEFT JOIN cv_task t on t.id = u.task_id
        where u.deleted = 0
        AND u.team_id = ?
         
         
         
         
         
         
            and t.audit_type != 5 ::: [122]






At 2019-12-04 17:12:38, "[email protected]" <[email protected]> wrote:
>Hi,
>
>I just answer the questions.
>
>For question 1:
>
>The sharding strategy you provide is too complicated, can you try the
>simple sharding strategy first and make sure the strategy is work fine as
>you want?
>We just concentrate the tech point of ShardingSphere, we need split
>business logic first and then we can discuss about ShardingSphere future.
>
>For question 2:
>
>Please provide your ShardingSphere version number and logs of `sql.show`,
>it is necessary to let us debug and reproduce the bug.
>
>For question 3:
>
>We need logs of `sql.show` to get your actual SQL too, please provide it.
>
>
>A last, I have a suggestion, mailing-list should for search friendly, so it
>is better separate your 3 questions to 3 different emails and give every
>email a good title.
>
>------------------
>
>Liang Zhang (John)
>Apache ShardingSphere & Dubbo
>
>
>xu <[email protected]> 于2019年12月4日周三 下午4:53写道:
>
>> Question 1:
>>
>> I have configured a strategy of sub table:
>>
>> The configuration file is as follows:
>>
>>
>>
>> <bean id="preciseModuloTableShardingAlgorithm"
>> class="com.jd.bdp.cv.common.PreciseModuloShardingTableAlgorithm" />
>> <bean id="rangeModuloShardingTableAlgorithm"
>> class="com.jd.bdp.cv.common.RangeModuloShardingTableAlgorithm" />
>>
>> <sharding:standard-strategy id="tableShardingStrategy"
>> sharding-column="task_id"
>> precise-algorithm-ref="preciseModuloTableShardingAlgorithm"
>> range-algorithm-ref="rangeModuloShardingTableAlgorithm"/>
>>
>>
>> <sharding:data-source id="shardingDataSource">
>>     <sharding:sharding-rule data-source-names="cv_dataSource">
>>         <sharding:table-rules>
>>             <sharding:table-rule logic-table="cv_user_task"
>> actual-data-nodes="cv_dataSource.cv_user_task_${0..1}"
>> table-strategy-ref="tableShardingStrategy"  />
>>         </sharding:table-rules>
>>        <!-- <sharding:binding-table-rules>
>>             <sharding:binding-table-rule
>> logic-tables="t_order,t_order_item"/>
>>         </sharding:binding-table-rules>
>>         <sharding:broadcast-table-rules>
>>             <sharding:broadcast-table-rule table="t_address"/>
>>         </sharding:broadcast-table-rules>-->
>>    </sharding:sharding-rule>
>>     <sharding:props>
>>         <prop key="sql.show">true</prop>
>>     </sharding:props>
>> </sharding:data-source>
>>
>>
>>
>>
>>
>> My sub table logic is as follows:
>>
>>
>>
>> if (shardingValue.getValue()<7800){
>>     return  "cv_user_task_0";
>>
>> }
>> else {
>>     Long modValue = shardingValue.getValue() % tableNames.size();
>>     String modStr = modValue.toString();
>>     for (String each : tableNames) {
>>         if (each.endsWith(modStr)) {
>>             return each;
>>         }
>>     }
>> }
>>
>>
>> throw new IllegalArgumentException();
>>
>>
>>
>> The specific logic is as follows: in order to be compatible with the old
>> data, when the shardingvalue is less than a certain value (such as 1230),
>> query the previous table, and when it is greater than a certain value, use
>> the table splitting logic. The sub table logic is routed according to the
>> modular operation. But I found that this logic did not take effect. There
>> are two specific problems:
>>
>> 1. When debugging, you can only enter the doshading method for the first
>> time, and then the breakpoint will not enter.
>>
>> 2. All the table fields in my database are smaller than 1230, so the
>> original table CV user task should be selected according to the logic, but
>> still go to CV user task 0, CV user task 1 from the console
>>
>>
>>
>> And no data can be found. So I suspect that if the table is not defined in
>> the actual data nodes = "cv_datasource. Cv_user_task" ${0.. 1} ", the data
>> cannot be queried. After testing, I found that my suspicion is correct. It
>> can be queried to put the historical data into the two tables CV ﹣ user ﹣
>> task ﹣ 0 and CV ﹣ user ﹣ task ﹣ 1. But what about my historical data? (must
>> data migration be performed)
>>
>> Question two:
>> After I use sharding, the function now () in SQL is not supported (using
>> mybatis)
>>
>> Report errors:
>>
>>        Data truncation: Incorrect datetime value: 'now()' for column
>> 'created' at row 1
>>
>>
>>
>> Question three:
>>
>>
>>
>> To test my sub table logic, it is written as follows:
>>
>>
>>
>> @Override
>> public String doSharding(final Collection<String> tableNames, final
>> PreciseShardingValue<Long> shardingValue) {
>>
>>
>>     return  "cv_user_task_0";
>>
>> }
>>
>> I configured the return values to cv_user_task_0
>>
>>
>>
>> But from the console
>>
>>
>>
>> Both CV user task 0 and CV user task 1 are not valid at all. The queried
>> data is also in the CV user task table.
>>
>>
>>
>> Is it because of my configuration?
>>
>>
>>
>>
>>
>>
>>

Reply via email to