michaellavelle / spring-data-dynamodb

Simplifies the development of creating an Amazon DynamoDB-based Java data access layer
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
169 stars 284 forks source link

Batch operations(insert) facility #23

Closed jAddict7 closed 10 years ago

jAddict7 commented 10 years ago

Hi, I need to batch insert my contents into dynamodb and is there support for it to achieve that. That is I will be sending variable sized list from request and I have to enter its instance one by one into table.

For example, we have to save for a rate plan data, sample data, 1-2 days: 30$ 2-4 days: 30$ 4-6 days: 50$ 6-10 days: 50$

sometimes the data can be lesser and more, so I decided to save this in separate table as separate entry for each instance of data and link with hash key attribute. In dynamoDB, Batch operations are allowed and is it possible in our project to achieve that. I have searched for samples and I dint get, please help me solve this problem.

I have been using spring-data-dynamodb to create connect my API with dynamodb, its really easy to use and thanks for this awesome work. Thank you.

michaellavelle commented 10 years ago

Hi - thanks for your interest in spring-data-dyanmodb - I'm glad you're finding the project useful.

Regarding saving data in batch - if the entities you are saving are all of the same type, saved into the same DynamoDB table, there is a save method on the repository interfaces which takes an Iterable as an argument. Using this method you can pass in a list of entities ( of the same type ) and save in batch, as this method calls dynamoDBMapper.batchSave method. Hope this helps, thanks, Michael

jAddict7 commented 10 years ago

Thanks for the reply Michael, How can use this batchSave in my project. Is there any samples available?

michaellavelle commented 10 years ago

If you take a look at the README for the project, in the test client example shown there is a call to repository.save(..). This save takes a single entity, but you can pass in a list of entities instead to save a batch of entities.

jAddict7 commented 10 years ago

Thank you Michael. Its really simple to achieve that and sorry for my unknown for that. Am new to springs so that cant get you by that time. Thank you once again Michael.