具有DynamoDB和MySQL双数据源的Spring数据/JPA存储库 [英] Spring Data/JPA Repositories with DynamoDB and MySQL dual datasources

查看:107
本文介绍了具有DynamoDB和MySQL双数据源的Spring数据/JPA存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉如何使Spring通过多个持久性单元和多个entityManagerFactoryBean实现动态处理多个数据源,但我正在努力解决的问题是如何拥有MySQL方言 DynamoDB方言通过相同的spring配置,通过spring-config xml文件.

I'm familiar with how to make Spring handle multiple datasources dynamically via multiple persistence-units and multiple entityManagerFactoryBean implementations but what I'm struggling with is how to have a MySQL dialect and a DynamoDB dialect from within the same spring configuration, via spring-config xml files.

工作模式如下:

[从某个端点输入数据POJO]->将POJO持久化到DynamoDB中,检索该对象的UUID(业务键作为POJO上的字段)->将UUID持久化为复合键(无引用完整性,这只是另一列)(与其他相关的映射实体)一起放入MySQL数据库.

[data POJO in, from some endpoint] -> Persist POJO into DynamoDB, retrieving the UUID of that object (business key as field on POJO) -> Persist UUID as a compound key (no referential integrity, it's just another column) into MySQL Database [with other related mapped entities].

我正在为将DynamoDB实例添加到Spring配置文件中以实现这一目标而苦苦挣扎.

I'm struggling with quite how on earth to go about adding the DynamoDB instance into the Spring configuration files to achieve this.

就其价值而言,相关的存储库将放在单独的程序包中.

For what it's worth, the related repositories are going to be in separate packages.

我们将不胜感激地接受任何10人入围!我已经做了一些搜索,但是所有DynamoDB映射器框架似乎都处于更高的水平-我在这里错过了什么吗?我一直在查看 Spring-Data DynamoDB ,但仍然无法建立两者之间的链接配置文件和Dynamo.

Any starters for 10 would be gratefully received! I've done some searching but all DynamoDB mapper frameworks seem to be at a much higher level - have I missed something here? I've been looking at Spring-Data DynamoDB but still can't make the link between the configuration file and Dynamo.

预先感谢

A.

==========思维更新=========

========= UPDATE IN THINKING =========

我认为我做错了这条路.从更多地研究样本到进行本地集成测试[pure dynamodb],我认为不可能将DynamoDB用作EntityManager Factory实现的一部分:为此,我认为我将不得不创建"我自己的存储库实现,该实现调用Dynamo的映射器和AWS连接帮助器类等,而不使用任何JPA spring提供的代码.

I think I've gone about this the wrong way. From digging around the samples a lot more, doing a local integration test [pure dynamodb], I don't think it's possible to use DynamoDB as part of an EntityManager Factory implementation: to that end, I think I'm going to have to "create" my own repository implementations that call out to the mapper and AWS connection helper classes etc. for Dynamo, rather than using any of the JPA spring-provided code.

除非任何人可以推荐/建议否则?

Unless anyone can recommend/suggest otherwise?

推荐答案

问题已解决-经过大量研究,唯一的真正方法是引入自己对存储库和基于DAO的实现的解释.

Question closed - after much investiation the only real way to do it is to introduce ones own interpretation of a repository and DAO-based implementation.

有一个有趣的项目, Spring Data Dynamodb .看起来很有趣,但尚未为企业生产版本做好准备.

There is one interesting project, however, Spring Data Dynamodb. Looks interesting but not quite ready for Enterprise Production release.

这篇关于具有DynamoDB和MySQL双数据源的Spring数据/JPA存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆