How to bind entity to different tables with SpringJPA/SpringBoot
I want to design a system. There are different customers using this system. I need to create the duplicated tables for every customer. For example, I have a table Order
, then all of order records for customerA
are in table Order_A
, as well as customerB
data are in table Order_B
. I can distinct different customers from session, but how can I let Spring JPA to reflect the RDS table data to Java object?
I know 2 solutions, but both are not satisfied.
- Consider to use Mybatis because it supports load SQL from xml file and parameters inside SQL;
- Consider to use
org.hibernate.EmptyInterceptor
. This is my current implement in my project. For every entity, I must define a subclass of it. It can update the SQL before Hibernate's execution. However, both are not graceful. I prefer the better solution.
Comments
Post a Comment