Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data/JPA Repositories with DynamoDB and MySQL dual datasources

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.

The work pattern is as follows:

[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].

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.

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.

Thanks in advance,

A.

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

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?

like image 472
Al Sweetman Avatar asked Jan 20 '14 17:01

Al Sweetman


1 Answers

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.

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

like image 178
Al Sweetman Avatar answered Oct 02 '22 20:10

Al Sweetman