【问题标题】:Does Spring Data's Cross-Store persistence support Document->JPA or Collections?Spring Data 的 Cross-Store 持久化是否支持 Document->JPA 或 Collections?
【发布时间】:2012-04-07 15:45:14
【问题描述】:

我正在为当前项目评估跨商店设计,我们正在考虑同时使用 MySQL 和 MongoDB。

独立地,每个产品的 Spring 支持都非常出色。但是,跨商店支持似乎更加前沿。

阅读了documentation,我还有几个问题:

文档谈到了对 JPA 实体的跨商店支持,该实体包含一个作为@Document 持久化的属性。是否存在相反的支持?即,我可以将 MongoDB 文档作为父文档,其中包含对 JPA 实体(或实体集合)的引用吗?

例如:

 @Document
 public class Product
 {
      @Entity?
      private Manufacturer manufacturer;

      @CollectionOfEntities?
      private List<Review> reviews
 }

同样,是否支持持久化包含文档集合的 JPA 实体?

例如:

 @Entity
 public class Shop
 {
       @Id
       private Long id;
       // Product is a MongoDB @Document
       private List<Product> products;
 }

支持吗?

鉴于跨存储持久性如此新,是否有任何设计最佳实践的资源或需要避免的陷阱?

【问题讨论】:

    标签: java spring mongodb jpa


    【解决方案1】:

    我不确定跨商店。但是,EclipseLink(从 2.4 开始)支持 MySQL 和 MongoDB 的 JPA,并且确实支持复合持久性单元,允许跨持久性单元的关系。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-29
      相关资源
      最近更新 更多