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/10/22 07:07:42 UTC

[GitHub] [shardingsphere] heqiao edited a comment on issue #7703: Can not update sharding key, logic table: [**], column: [**]

heqiao edited a comment on issue #7703:
URL: https://github.com/apache/shardingsphere/issues/7703#issuecomment-714274455


   > > There is indeed a workaround - Embed the primary key and sharding key on the entity level. So the sharding key is disguised as part of JPA's id. Not pretty, but works... However, it's definitely not something that I could promote to coworkers "Hey we should use this cool sharding tool, and it works with JPA only if you carefully configure it"
   > 
   > It would be great if you could share an example!
   
   ```
   @Embeddable
   @Data
   public class CompositeId implements Serializable {
       private Long id; // pk
       private String accountId; // sharding key
   }
   
   @Table("xxxx")
   @Entity 
   public class YourClass {
       @EmbeddedId
       private CompositeId compositeId;
   }
   ```
   
   Then you can do findByCompositeIdAccountId.


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