Skip to content

Commit 1f6be4d

Browse files
#55 Fixing issue with count by hash and count by hash and range queries
1 parent d20b09f commit 1f6be4d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/org/socialsignin/spring/data/dynamodb/query/CountByHashAndRangeKeyQuery.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ public class CountByHashAndRangeKeyQuery<T> extends AbstractSingleEntityQuery<Lo
2424

2525
private Object hashKey;
2626
private Object rangeKey;
27+
private Class<T> entityClass;
2728

2829
public CountByHashAndRangeKeyQuery(DynamoDBOperations dynamoDBOperations, Class<T> clazz, Object hashKey, Object rangeKey) {
2930
super(dynamoDBOperations, Long.class);
3031
this.hashKey = hashKey;
3132
this.rangeKey = rangeKey;
33+
this.entityClass = clazz;
3234
}
3335

3436
@Override
3537
public Long getSingleResult() {
36-
return dynamoDBOperations.load(clazz, hashKey, rangeKey) == null ? 0l : 1l;
38+
return dynamoDBOperations.load(entityClass, hashKey, rangeKey) == null ? 0l : 1l;
3739
}
3840

3941
}

src/main/java/org/socialsignin/spring/data/dynamodb/query/CountByHashKeyQuery.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323
public class CountByHashKeyQuery<T> extends AbstractSingleEntityQuery<Long> implements Query<Long> {
2424

2525
private Object hashKey;
26+
private Class<T> entityClass;
2627

2728
public CountByHashKeyQuery(DynamoDBOperations dynamoDBOperations, Class<T> clazz, Object hashKey) {
2829
super(dynamoDBOperations, Long.class);
2930
this.hashKey = hashKey;
31+
this.entityClass = clazz;
3032
}
3133

3234
@Override
3335
public Long getSingleResult() {
34-
return dynamoDBOperations.load(clazz, hashKey) == null ? 0l : 1l;
36+
return dynamoDBOperations.load(entityClass, hashKey) == null ? 0l : 1l;
3537
}
3638

3739
}

0 commit comments

Comments
 (0)