简体   繁体   English

尝试将Crate.io NoSql数据库与现有的Spring Data / Mysql项目一起使用

[英]Trying to use Crate.io NoSql database with an existing Spring Data / Mysql project

I'm attempting to add Crate.IO capability to an existing Spring Data/Eclipselink/MySql web application. 我正在尝试将Crate.IO功能添加到现有的Spring Data / Eclipselink / MySql Web应用程序中。 For this specific use case, we want to persist data to both MySql AND Crate (for evaluation purposes) in the most painless way possible. 对于这个特定用例,我们希望以最轻松的方式将数据保存到MySql和Crate(用于评估目的)。 I'm using the Spring-Data-Crate project in order to be able to use Spring Data Repositories with Crate. 我正在使用Spring-Data-Crate项目,以便能够使用Crate的Spring Data Repositories。

I've been able to setup a separate Crate specific entity manager with a filter to only utilize repos that implement CrateRepository. 我已经能够使用过滤器设置一个单独的Crate特定实体管理器,以仅使用实现CrateRepository的repos。 The problem I'm having is determining how to use the existing Spring Data/MySql entity classes with Crate. 我遇到的问题是确定如何将现有的Spring Data / MySql实体类与Crate一起使用。 (or derive from them) (或从中衍生出来)

1) If I annotate an existing Spring Data @Entity class with the Spring-Data-Crate @Table annotation, the mapping to the crate DB will fail because EclipseLink/JPA adds hidden persistence fields to entities objects that start with an underscore, which is apparently not allowed by the spring-data-crate adapter 1)如果我使用Spring-Data-Crate @Table注释注释现有的Spring Data @Entity类,则对crate DB的映射将失败, 因为EclipseLink / JPA将隐藏的持久性字段添加到以下划线开头的实体对象,这是显然不允许使用spring-data-crate适配器

2) I tried to use entity inheritance, with a base class that both the MySql and Crate entity can extend, with only the MySql entity having the spring data @Entity annotation. 2)我尝试使用实体继承,使用MySql和Crate实体都可以扩展的基类,只有具有spring数据@Entity注释的MySql实体。 Unfortunately, this causes Spring Data to lose visibility of the base class fields unless the base class is annotated with @MappedSuperClass. 不幸的是,这导致Spring Data失去对基类字段的可见性,除非基类使用@MappedSuperClass注释。 But adding this annotation introduces the hidden "_"-prefixed persistence properties to the derived crate entity. 但添加此注释会将隐藏的“_” - 前缀持久性属性引入派生的crate实体。

3) I could use separate entities entirely and have them implement a common interface, but I can't assign the interface as the type of the spring data crate repository. 3)我可以完全使用单独的实体并让它们实现一个公共接口,但我不能将接口指定为spring数据包存储库的类型。

... Not sure where to go from here ......不知道从哪里开始

Spring Data Crate adapter project - https://github.com/KPTechnologyLab/spring-data-crate Spring Data Crate Tutorial - https://crate.io/a/using-sprint-data-crate-with-your-java-rest-application/ Spring Data Crate适配器项目 - https://github.com/KPTechnologyLab/spring-data-crate Spring Data Crate教程 - https://crate.io/a/using-sprint-data-crate-with-your-java-其余的应用程序/

i'm johannes from crate. 我是来自箱子的约翰内斯。 we didn't test the use of spring data crate in that manner so we can't state any information if this should or shouldn't work. 我们没有以这种方式测试弹簧数据箱的使用,因此如果这应该或不应该起作用,我们就不能说明任何信息。 sorry, johannes 抱歉,约翰内斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM