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 2021/05/07 15:56:23 UTC

[GitHub] [shardingsphere] XUZHOUWANG opened a new issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

XUZHOUWANG opened a new issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274


   **table:**
   
   @TableName("t_user")
   @Data
   public class User implements Serializable {
   
       @TableId(type = IdType.INPUT)
       private Long id;
       private String name;
       private Date gmtCreate;
       private Date gmtModified;
       private String phone;
       private Integer isDeleted;
   
   }
   
   **config**
   
    sharding:
         tables:
           t_user:
             actual-data-nodes: skshardingjdbc.t_user_$->{0..1}
             logicTable: t_user
             tableStrategy:
               inline:
                 shardingColumn: id
                 algorithmExpression: t_user_$->{id % 2}
             keyGenerator:
               type: UUID
               column: id
   
   **error** 
   
   ### SQL: INSERT INTO t_user  ( id, name, gmt_create, gmt_modified, phone )  VALUES  ( ?, ?, ?, ?, ? )
   ### Cause: java.lang.IllegalArgumentException: Sharding value must implements Comparable.
   	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:199)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
   	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:498)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
   	... 37 more


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



[GitHub] [shardingsphere] avalon5666 commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-834990739


   Follow step 1 ~ 2


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



[GitHub] [shardingsphere] XUZHOUWANG commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
XUZHOUWANG commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-834987969


   > 1. Use "@TableId(type = IdType.AUTO)"
   > 2. id's type in class not match uuid
   
   no,I want to create the id by shardingsphere; the definition of  User is okay.


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



[GitHub] [shardingsphere] avalon5666 commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-834965315


   1. Use "@TableId(type = IdType.AUTO)"
   2. id's type in class not match uuid


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



[GitHub] [shardingsphere] avalon5666 closed issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 closed issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274


   


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



[GitHub] [shardingsphere] XUZHOUWANG commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
XUZHOUWANG commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-834987100


   https://blog.csdn.net/qiaoqiyu6416/article/details/107044664/


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



[GitHub] [shardingsphere] avalon5666 edited a comment on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 edited a comment on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-835003426


   "IdType.AUTO" is created by the database,it will create by shardingsphere database middleware,mybatis-plus do nothing.


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



[GitHub] [shardingsphere] avalon5666 commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-835001605


   How to confirm the id is created by the mybatis-plus framework?


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



[GitHub] [shardingsphere] XUZHOUWANG commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
XUZHOUWANG commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-835009849


   > "IdType.AUTO" is created by the database,it will create by shardingsphere database middleware,mybatis-plus do nothing.
   
   it's okay. I try it. it's fine. I know the "IdType.ASSIGN_ID" procedure. But I don't really try the "IdType.AUTO". thank you


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



[GitHub] [shardingsphere] avalon5666 commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-834962325


   Use "@TableId(type = IdType.AUTO)"


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



[GitHub] [shardingsphere] avalon5666 commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-835003426


   "IdType.AUTO" is created by the database,it will create by shardingsphere database middleware


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



[GitHub] [shardingsphere] avalon5666 removed a comment on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
avalon5666 removed a comment on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-834962325


   Use "@TableId(type = IdType.AUTO)"


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



[GitHub] [shardingsphere] XUZHOUWANG commented on issue #10274: The primary key is sharding column created the key value by the GeneratedKey config 。 is it okay?

Posted by GitBox <gi...@apache.org>.
XUZHOUWANG commented on issue #10274:
URL: https://github.com/apache/shardingsphere/issues/10274#issuecomment-834999874


   > Follow step 1 ~ 2
   
   it‘s okay. but i want to the value of the   primary key  created by the snowflake set by the sharding configuration. while step 1~2,the id is created by the mybatis-plus framework.


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