You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When upgrading to spring-data-aerospike 4.6.0 from version 3.4.1, we started encountering the following errors when trying to use @Cacheable with entities that did not have an @Id property present.
com.aerospike.client.AerospikeException: Error 26: Id has not been provided
at org.springframework.data.aerospike.convert.MappingAerospikeWriteConverter.getNewKey(MappingAerospikeWriteConverter.java:144)
at org.springframework.data.aerospike.convert.MappingAerospikeWriteConverter.write(MappingAerospikeWriteConverter.java:93)
at org.springframework.data.aerospike.convert.MappingAerospikeConverter.write(MappingAerospikeConverter.java:83)
at com.wayfair.waycomm.garage.config.helpers.AerospikeConfigurationHelper$2.write(AerospikeConfigurationHelper.java:67)
at com.wayfair.waycomm.garage.config.helpers.AerospikeConfigurationHelper$2.write(AerospikeConfigurationHelper.java:52)
at org.springframework.data.aerospike.cache.AerospikeCache.serializeAndPut(AerospikeCache.java:204)
We have verified that this issue can be addressed by forking the code and updating AerospikeCache.serializeAndPut() to set the key on the AerospikeWriteData before calling the converter as shown below:
private void serializeAndPut(WritePolicy writePolicy, Object key, Object value) {
Key aerospikeKey = getKey(key);
AerospikeWriteData data = AerospikeWriteData.forWrite(aerospikeKey.namespace);
data.setKey(aerospikeKey); // Set the key on the data object
aerospikeConverter.write(value, data);
client.put(writePolicy, aerospikeKey, data.getBinsAsArray());
}
Can a change like this be made to the project? If you want me to open a PR I'd be happy to do so if provided with guidance. Thanks!
The text was updated successfully, but these errors were encountered:
Hello @dhamilton!
The code you have provided looks legitimate, it would be great if you open a PR with the change and also with a relevant test. To do that you can fork the Spring Data Aerospike repository, make the changes and open a pull request which we will then review.
Thanks!
Entities in cached methods will not require having an id starting with the next release.
Please note: few changes have been introduced (cache key is now a hash and not a result of toString(), the signature of AerospikeCacheManager class has changed).
When upgrading to spring-data-aerospike 4.6.0 from version 3.4.1, we started encountering the following errors when trying to use
@Cacheable
with entities that did not have an@Id
property present.This is a regression from v3. Looking at
MappingAerospikeWriteConverter.java
we see that the requirement for an@Id
property is not enforced if theAerospikeWriteData
object has already been populated with a key (https://github.com/aerospike/spring-data-aerospike/blob/main/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java#L119). Furthermore, the requirement serves no purpose sinceAerospikeCache.java
uses the key provided to the cache API when writing the object (https://github.com/aerospike/spring-data-aerospike/blob/main/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java#L205).We have verified that this issue can be addressed by forking the code and updating
AerospikeCache.serializeAndPut()
to set the key on theAerospikeWriteData
before calling the converter as shown below:Can a change like this be made to the project? If you want me to open a PR I'd be happy to do so if provided with guidance. Thanks!
The text was updated successfully, but these errors were encountered: