Skip to content

Commit dbabfea

Browse files
committed
Fixed a small bug in checkbooks
1 parent 90955dc commit dbabfea

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/test/java/com/aerospike/mapper/example/model/Address.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.aerospike.mapper.annotations.AerospikeRecord;
66
import com.aerospike.mapper.annotations.ParamFrom;
77

8+
// Addresses are only ever embedded in parent records, so do not need information to map to Aerospike.
89
@AerospikeRecord
910
public class Address {
1011
@AerospikeKey

src/test/java/com/aerospike/mapper/example/model/Checkbook.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
@AerospikeRecord(namespace = "test", set = "chkbook")
1010
public class Checkbook {
11-
private final String acctId;
12-
private final long first;
13-
private final long last;
11+
private String acctId;
12+
private long first;
13+
private long last;
1414
private final Date issued;
1515
private boolean recalled;
1616
private Branch issuer;
@@ -51,6 +51,7 @@ public void setIssuer(Branch issuer) {
5151
this.issuer = issuer;
5252
}
5353

54+
/* The checkbook class does not have a key in it's own right, it uses a composite key */
5455
@AerospikeKey
5556
public String getKey() {
5657
return String.format("%s-%d-%d", acctId, first, last);
@@ -59,6 +60,9 @@ public String getKey() {
5960
@AerospikeKey(setter = true)
6061
public void setKey(String key) {
6162
int index = key.lastIndexOf('-');
62-
63+
this.last = Long.parseLong(key.substring(index+1));
64+
int firstIndex = key.lastIndexOf('-', index-1);
65+
this.first = Long.parseLong(key.substring(firstIndex+1, index));
66+
this.acctId = key.substring(0, firstIndex);
6367
}
6468
}

0 commit comments

Comments
 (0)