Cannot getBy(globalsecondaryIndexName) in spring boot using CRUD repository

18 Views Asked by At

I have an entity in which I have created GSI for an attributr called loginId

`    @DynamoDBIndexHashKey(globalSecondaryIndexName = "login_id")
    private String loginId;`

I have annotated loginId like this in my entity class

and then in my custom repository I have defined a function like this

List<Myentity> findByLoginId(String loginId);

when I am using this function in my service class it throws an exception

com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException: Cannot do operations on a non-existent table

which I guess means the table with GSI as PK is not created, but I saw my table configuration I can clearly see


  "GlobalSecondaryIndexes": [
    {
      "IndexName": "login_id",
      "KeySchema": [
        {
          "AttributeName": "loginId",
          "KeyType": "HASH"
        }
      ],
      "Projection": {
        "ProjectionType": "ALL"
      },
      "IndexStatus": "ACTIVE",
      "ProvisionedThroughput": {
        "ReadCapacityUnits": 20,
        "WriteCapacityUnits": 20
      },
      "IndexSizeBytes": 614,
      "ItemCount": 1,
      "IndexArn": "arn:aws:dynamodb:ddblocal:000000000000:table/{myTableName}/index/login_id"
    }
  ], 

I know I can create a custom DynamoDbQueryExpression and query using dynamodbmapper but I don't want to do it in that way , I wanted to use the above function (findByLoginId)

please help me , how can I resolve this issue

and also I have seen some functions in the different repository like

findByUserIdOrderByCreatedDesc findBySearchKeyAndCreatedGreaterThanOrderByCreatedDesc

these looks like sql statements in english , what are these functions called and how can I use them

I tried with DynamoDbQueryExpression and dynamoDb mapper ,but I need to know this method too

0

There are 0 best solutions below