Spring Data多表通用存储库

时间:2018-03-23 18:13:27

标签: spring rest generics spring-data spring-data-jpa

我的应用程序具有未知数量的表,这些表符合两种结构中的一种。标准和超大。不幸的是,直到运行时我才知道架构中有多少表对应标准或超大?

我已经创建了通用的Standard和Outsized存储库,如此

public interface StandardTableRepository<T extends AbstractStandardTable>
    extends CrudRepository<T, Long> {}

但由于架构不是静态的,我不能创建实体直到运行时?

我理解JPA并不能真正满足非静态模式,但有没有办法可以公开一个通用的restful服务,它允许我在运行时使用QueryParams中提供的表名实例化这个存储库?

0 个答案:

没有答案
相关问题