heqiao commented 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
   }
   ```
   
   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:
[email protected]


Reply via email to