I've a micro-services architecture system using spring boot. The service A, has its model classes (A1, A2, A3) SOME OF WHICH, should be reusable by services B, C, D... Each service (B, C, D) has its own local database and doesn't need to keep track of all Service A entities, just the a few ones.
All Service A, model classes are anottated @Entity
How can I achieve this behavior using spring-boot hibernate.
Trying to make an specific example:
I've a jar, containing only @Entityclasses, i'm interested in importing a few of this classes in my project and generating the respective tables for that, but completing ignoring most of the classes
I've @EntityScan(basePackageClasses = {ServiceAModel1.class, ServiceAModel2.class})
but it scan the whole package and inevitably adds all model classes to entitymanager and so fails if the local service doesn't create tables for any of this classes
how can i approach this problem?
If you share something between services, you should create a package with the common entities and release and manage them separately.
So create a common-entities package that includes all entities you want to share and import it into services A, B, C and D. This way only the entities you want to share are exposed.