spring-data-dynamodb | Amazon DynamoDB-based Java data access layer
kandi X-RAY | spring-data-dynamodb Summary
kandi X-RAY | spring-data-dynamodb Summary
The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use data access technologies. This module deals with enhanced support for a data access layer built on AWS DynamoDB. Technical infos can be found on the project page.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Retrieves all entities matching the specified pageable
- Reads a page of results from a paginated scan list
- Scans through a paginated scan list
- Builds a fetch query for the given index
- Gets the global secondary index name
- Builds the DynamoDB query expression
- Returns the overridden attribute name
- Gets overridden attribute name
- Apply a property to the criteria
- Sets a range key equal to the specified value
- Builds a query to look for a DynamoDB table
- Called after the proxy factory completes
- Publish an application event
- Adds the global secondary indexes
- Determine whether the given type is persistent
- An observer function
- Gets the property names of the index range key
- Parse a single bean definition
- Retrieves multiple entities
- Returns a type converter for the specified property
- Override to validate the given object
- Counts the elements of a mutable query
- Returns the marshaller for the specified property
- Gets the bean after initialization
- Check to see if the spec is compatible
- Overridden to register all beans in the repository
spring-data-dynamodb Key Features
spring-data-dynamodb Examples and Code Snippets
Community Discussions
Trending Discussions on spring-data-dynamodb
QUESTION
Repository perform a query over a method that only uses hashKey and rangeKey attributes, and result this:
...ANSWER
Answered 2020-Nov-12 at 22:51After trying random changes in entity. I got the expected result in the repository method.
Correct way to map a Entity with composite key
QUESTION
I'm developing the following rest services:
GET /parents
- Get all parents
GET /parents/{id}
- Get parent by id
POST /parents
- Add new parent
GET /parents/{pid}/children
- Get all children for parent pid
GET /parents/{pid}/children/{id}
- Get child by id for parent pid
POST /parents/{pid}/children
- Add new child for parent pid
GET /parents/{pid}/children/{cid}/subchildren
- Get all subchildren for parent pid and child cid
GET /parents/{pid}/children/{cid}/subchildren{id}
- Get subchildchild by id for parent pid and child cid
POST /parents/{pid}/children/{cid}/subchildren
- Add new subchild for parent pid and child cid
I have to use DynamoDB (or some other serverless and cheap database option on AWS) for performing CRUD operations (Update and Delete are not a priority as of now).
When GET /parents
is called, the response will be:
ANSWER
Answered 2020-Sep-06 at 09:51You can do several things:
A: better for cost/performance but requires a bit of extra work
In your table, create a partition key PK
and order key OK
as both strings (you can use whatever name you want for the keys of course, this is just an example - my point being, the keys are not in your data model, you have to create them upon insert). When you create your items, don't store them as a one big document but store parents, children and subchildren separately. Each item gets as PK
the value parent
/child
/subchild
, and as OK
the value that you have in each item's name
as it has the right parentname_childname_subchildname kind of inheritance, or you can construct it from each item's parents properties.
Upon retrieval, you can get all subchildren of a given parent for example with an expression such as where PK = subchild and OK begins_with parentname_
which effectively returns all items that are subchilds and that belong to a given parent, no matter what the child is. Il you want to also filter on the child, you can do begins with parentname_childname_
. If you want only the children of a parent, you can do where PK = child and OK begins_with parentname_
. If you know precisely what child you want, instead of using begins_with
you can simply do where PK = child and OK = parentname_childname
. And so forth... (I'm using SQL-like syntax for ease of writing/reading but it's easy enough to convert to dynamodb query language).
The idea is too differentiate your item's actual attributes and how you retrieve your item. You can create completely bogus keys if it helps you find your items easily!
You may not event need to differentiate the child "levels" in the PK, and you could as well use just a generic value there for similar results. The main objective of this method is to have an order key to use begins_with
on in a particular partition key.
The main problem with this method is that once you have all your parents/children/subchildren as in your /parents
example, you will have to reconstruct the tree entirely in code. But as far as dynamodb is concerned, this is probably the most optimized solution.
B: easier option using filters, but (much) worse cost/performance
Store each parent in a big document then scan your table with a filter like where item.children[].subchildren[].name = parentname_childname_subchildname
. It's not quite as efficient and costs much more, as filters are applied on the results of the query so you are retrieving everything first then filtering only what you want, so you pay for all the items first then cut out those you don't want. It works but it's not great, especially if you want something like 5 items out of 100000.
Main advantage is that for /parents
call, you get the whole hierarchy as described. But for subroutes /parents/x/children/...
you will need to either reformat the object in your code or query only sub attributes in the projection expression.
C: using local secondary indexes
A bit like solution A where you store items separately, with the same PK for all items but with a local secondary index with 3 different order keys: name_parent
, name_child
, name_subchild
. Then you can query each index separately depending on what you want. For this use case it's better to use LSIs than GSIs for cost optimization, but you are free to implement the same idea with GSIs. It will work just as well (with the same limitations about reformatting parent elements to contain children elements as well).
QUESTION
The below implementation is working with SpringBoot version 2.0.2.RELEASE.
After some dependencies upgrade the code fails to autowire DataRecordDBItemRepository
.
The upgrades were:
...ANSWER
Answered 2020-Jun-28 at 12:04For setter injection to work, the setter method needs to follow Java bean conventions i.e., there should be setter method called set, here it should be setDataRecordDBItemRepository. Corrected the code and please have a try?
QUESTION
I'm trying to create a spring boot aplication with DynamoDB database, following this tutorial.
After adding the project dependencies, it seems that maven can't find the com.amazonaws
dependency, and that is causing a lot of errors in amazon variables, like @EnableDynamoDBRepositories
for example.
This is the actual code of:
pom.xml
...ANSWER
Answered 2020-May-05 at 18:37you have to include the dependency
QUESTION
I am using derjust/spring-data-dynamodb library to interact with DynamoDB. I have defined a class Product as follows:
...ANSWER
Answered 2020-Mar-30 at 11:43You can create a constant for globalSecondaryIndexName
with environment name,
QUESTION
When I run my Spring Boot 2.0.0 application with the current latest version of spring-data-dynamodb (v5.1.0) I get the following error at runtime.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamoDB-DynamoDBMapper': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory.()
I have tried the following things:
- Adding a DynamoDBMapperFactory bean to my configuration class and making it primary
- Different combinations of AWSCredentials, DynamoDBMapperConfig, DynamoDBMapper and AmazonDynamoDB bean configurations (e.g. removing them, making them primary, giving them names and explicitly referring to them)
- Different combintations of config passed to the EnableDynamoDBRepositories annotation
ANSWER
Answered 2020-Mar-09 at 23:50It turned out that spring-data-dynamo v5.1.0 was not compatible with my version of Spring Boot (2.0.0)
Downgrading the spring-data-dynamo library to v5.0.4 fixed my issues.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-data-dynamodb
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page