在运行时更改 table - Spring API 休息

Change table on runtime - Spring API Rest

现在,我有了下一个实体。这个是我数据库的m1table。

@Entity(name = "m1")
@Data
public class Information {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int id;

    private String date;
    private Double weight_1;
    private Double weight_2;
    private Double weight_3;
    private Double weight_4;
    private int working;

}

所以,当我打电话给API休息它returns我的信息对应m1 table。我拥有的控制器是下一个(returns 所有信息的简单控制器):

@Controller
@RequestMapping(path = "/information")
public class InformationController {

    @Autowired
    private InformationRepository repository;

    @GetMapping(path="/all")
    public @ResponseBody List<Information> getAllInformations() {
        // This returns a JSON or XML with the users
        return repository.findAll();
    }
}

问题是:有什么方法可以改变m1的名字在运行时。例如,我可以将 table 的名称放在调用路径中,然后放在 API 中吗?

也许这是不可能的,我正在以我不知道的糟糕方式做这件事。

编辑: 我的意思是,我可以通过将 table我想要在我调用的 url/path 中。例如:在我的情况下,APIRest取数据的默认table/entity是m1,我也可以调用 http://localhost:8080/information/especifictable/all/,其中 especific table 是我想要接收数据库数据的 table,在 API 中,Rest 接受 url 参数并更改默认 m1especifictable .

不知道有没有解释好,不知道怎么解释好

只有在数据库中有两个看起来相同的表时,这样的设计才有意义。如果是这种情况,则您的数据库设计有问题。

据我所知基本上是不可能的。