I have a legacy application with a database that splits up the data into multiple schemas on the same physical database. The schemas are identical in structure.
I use a microservice using Spring Boot Data JPA to do work on a single schema. Then to avoid code repetition, I created a router service that forwards the request to the single schema microservice replica each with a different database connection. But I found that a bit overkill (but works)
I am trying to reduce it back down to a single microservice. I haven't been successful yet, but I set up the tables with the schema
property.
@Table(
name = "alerts",
schema = "ca"
)
However, it gets confused when I try to do inheritance and @MappedSuperclass
to reduce the code duplication.
In addition the @OneToMany
breaks apart because of the inheritance getting errors like X references an unknown entity: Y
Basically is there a way of using inheritance on JPA that uses the same table structure with the difference being just the schema without copy and pasting too much code. Ideally I'd like to just pass a "schema" parameter to a DAO and it somehow does it for me.