4646/**
4747 * This is the base class for all classes performing the validation or
4848 * auto-creation of tables based on the entity classes.
49- *
49+ *
5050 * //TODO: It would be nice if the checks would run in parallel via a
5151 * TaskScheduler (if available)
52- *
52+ *
5353 * @see Entity2DDL
5454 */
5555public class Entity2DynamoDBTableSynchronizer <T , ID > extends EntityInformationProxyPostProcessor <T , ID >
@@ -60,6 +60,7 @@ public class Entity2DynamoDBTableSynchronizer<T, ID> extends EntityInformationPr
6060
6161 private static final String CONFIGURATION_KEY_entity2ddl_auto = "${spring.data.dynamodb.entity2ddl.auto:none}" ;
6262 private static final String CONFIGURATION_KEY_entity2ddl_gsiProjectionType = "${spring.data.dynamodb.entity2ddl.gsiProjectionType:ALL}" ;
63+ private static final String CONFIGURATION_KEY_entity2ddl_lsiProjectionType = "${spring.data.dynamodb.entity2ddl.lsiProjectionType:ALL}" ;
6364 private static final String CONFIGURATION_KEY_entity2ddl_readCapacity = "${spring.data.dynamodb.entity2ddl.readCapacity:10}" ;
6465 private static final String CONFIGURATION_KEY_entity2ddl_writeCapacity = "${spring.data.dynamodb.entity2ddl.writeCapacity:1}" ;
6566
@@ -68,18 +69,20 @@ public class Entity2DynamoDBTableSynchronizer<T, ID> extends EntityInformationPr
6869
6970 private final Entity2DDL mode ;
7071 private final ProjectionType gsiProjectionType ;
72+ private final ProjectionType lsiProjectionType ;
7173 private final ProvisionedThroughput pt ;
7274
7375 private final Collection <DynamoDBEntityInformation <T , ID >> registeredEntities = new ArrayList <>();
7476
7577 public Entity2DynamoDBTableSynchronizer (AmazonDynamoDB amazonDynamoDB , DynamoDBMapper mapper , Entity2DDL mode ) {
76- this (amazonDynamoDB , mapper , mode .getConfigurationValue (), ProjectionType .ALL .name (), 10L , 10L );
78+ this (amazonDynamoDB , mapper , mode .getConfigurationValue (), ProjectionType .ALL .name (), ProjectionType . ALL . name (), 10L , 10L );
7779 }
7880
7981 @ Autowired
8082 public Entity2DynamoDBTableSynchronizer (AmazonDynamoDB amazonDynamoDB , DynamoDBMapper mapper ,
8183 @ Value (CONFIGURATION_KEY_entity2ddl_auto ) String mode ,
8284 @ Value (CONFIGURATION_KEY_entity2ddl_gsiProjectionType ) String gsiProjectionType ,
85+ @ Value (CONFIGURATION_KEY_entity2ddl_lsiProjectionType ) String lsiProjectionType ,
8386 @ Value (CONFIGURATION_KEY_entity2ddl_readCapacity ) long readCapacity ,
8487 @ Value (CONFIGURATION_KEY_entity2ddl_writeCapacity ) long writeCapacity ) {
8588 this .amazonDynamoDB = amazonDynamoDB ;
@@ -88,6 +91,7 @@ public Entity2DynamoDBTableSynchronizer(AmazonDynamoDB amazonDynamoDB, DynamoDBM
8891 this .mode = Entity2DDL .fromValue (mode );
8992 this .pt = new ProvisionedThroughput (readCapacity , writeCapacity );
9093 this .gsiProjectionType = ProjectionType .fromValue (gsiProjectionType );
94+ this .lsiProjectionType = ProjectionType .fromValue (lsiProjectionType );
9195 }
9296
9397 @ Override
@@ -169,6 +173,11 @@ private boolean performCreate(DynamoDBEntityInformation<T, ID> entityInformation
169173 });
170174 }
171175
176+ if (ctr .getLocalSecondaryIndexes () != null ) {
177+ ctr .getLocalSecondaryIndexes ().forEach (lsi ->
178+ lsi .setProjection (new Projection ().withProjectionType (lsiProjectionType )));
179+ }
180+
172181 boolean result = TableUtils .createTableIfNotExists (amazonDynamoDB , ctr );
173182 if (result ) {
174183 TableUtils .waitUntilActive (amazonDynamoDB , ctr .getTableName ());
0 commit comments