【问题标题】:Have multiple repositories for the same class in spring data mongodb在 spring data mongodb 中为同一个类有多个存储库
【发布时间】:2018-10-22 16:18:33
【问题描述】:

所以我有一个数据类 x,我想拥有 2 个存储库。存储库 Y 和 Z 都应该能够存储 X 类型的文档。

问题是,当我在两个 repos 中使用 MongoRepository 时 .. 它假定集合名称是 X。所以我希望有一种方法可以为 Repository 重命名集合......或者更好的方法想在这里做

【问题讨论】:

    标签: java spring kotlin spring-data


    【解决方案1】:

    尝试使用继承并以这种方式定义适当的集合名称。可能使您可以保存在不同的集合中,但您仍然无法动态指定集合名称和相应的集合。它们在运行时的数量。

    【讨论】:

      猜你喜欢
      • 2016-07-06
      • 2015-10-19
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 1970-01-01
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      相关资源
      最近更新 更多