diff --git a/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java b/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java index 85dc3f3be..34018bffe 100644 --- a/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java +++ b/src/main/java/org/springframework/data/aerospike/cache/AerospikeCache.java @@ -184,7 +184,7 @@ private Key getKey(Object key){ } private void serializeAndPut(WritePolicy writePolicy, Object key, Object value) { - AerospikeWriteData data = AerospikeWriteData.forWrite(); + AerospikeWriteData data = AerospikeWriteData.forWrite(getKey(key).namespace); aerospikeConverter.write(value, data); client.put(writePolicy, getKey(key), data.getBinsAsArray()); } diff --git a/src/main/java/org/springframework/data/aerospike/convert/AerospikeWriteData.java b/src/main/java/org/springframework/data/aerospike/convert/AerospikeWriteData.java index a817bfa09..f3efcd512 100644 --- a/src/main/java/org/springframework/data/aerospike/convert/AerospikeWriteData.java +++ b/src/main/java/org/springframework/data/aerospike/convert/AerospikeWriteData.java @@ -51,8 +51,8 @@ public AerospikeWriteData(Key key, Collection bins, int expiration, Integer this.version = version; } - public static AerospikeWriteData forWrite() { - return new AerospikeWriteData(null, new ArrayList<>(), 0, null); + public static AerospikeWriteData forWrite(String namespace) { + return new AerospikeWriteData(new Key(namespace, "", ""), new ArrayList<>(), 0, null); } public void setKey(Key key) { diff --git a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java index 868adc424..9b65397ef 100644 --- a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java +++ b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeConverter.java @@ -84,5 +84,4 @@ public R read(Class type, final AerospikeReadData data) { public void write(Object source, AerospikeWriteData sink) { writeConverter.write(source, sink); } - } diff --git a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java index a929ec273..9f2b58d23 100644 --- a/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java +++ b/src/main/java/org/springframework/data/aerospike/convert/MappingAerospikeWriteConverter.java @@ -79,7 +79,7 @@ public void write(Object source, final AerospikeWriteData data) { String id = accessor.getProperty(idProperty, String.class); Assert.notNull(id, "Id must not be null!"); - data.setKey(new Key(entity.getNamespace(), entity.getSetName(), id)); + data.setKey(new Key(data.getKey().namespace, entity.getSetName(), id)); data.addBin(USER_KEY, id); } diff --git a/src/main/java/org/springframework/data/aerospike/core/AerospikeKeyValueAdapter.java b/src/main/java/org/springframework/data/aerospike/core/AerospikeKeyValueAdapter.java index 60d3e3fb4..eda3228c8 100644 --- a/src/main/java/org/springframework/data/aerospike/core/AerospikeKeyValueAdapter.java +++ b/src/main/java/org/springframework/data/aerospike/core/AerospikeKeyValueAdapter.java @@ -69,7 +69,7 @@ public AerospikeKeyValueAdapter(IAerospikeClient client, AerospikeConverter conv */ @Override public Object put(Object id, Object item, String keyspace) { - AerospikeWriteData data = AerospikeWriteData.forWrite(); + AerospikeWriteData data = AerospikeWriteData.forWrite(namespace); converter.write(item, data); client.put(null, data.getKey(), data.getBinsAsArray()); return item; diff --git a/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java index e2b092499..bbf368d09 100644 --- a/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/BaseAerospikeTemplate.java @@ -197,7 +197,7 @@ RuntimeException translateError(AerospikeException e) { } AerospikeWriteData writeData(T document) { - AerospikeWriteData data = AerospikeWriteData.forWrite(); + AerospikeWriteData data = AerospikeWriteData.forWrite(getNamespace()); converter.write(document, data); return data; } diff --git a/src/main/java/org/springframework/data/aerospike/mapping/AerospikeMappingContext.java b/src/main/java/org/springframework/data/aerospike/mapping/AerospikeMappingContext.java index 0a3ab2e3b..58f770adb 100644 --- a/src/main/java/org/springframework/data/aerospike/mapping/AerospikeMappingContext.java +++ b/src/main/java/org/springframework/data/aerospike/mapping/AerospikeMappingContext.java @@ -60,7 +60,7 @@ public void setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) { */ @Override protected BasicAerospikePersistentEntity createPersistentEntity(TypeInformation typeInformation) { - BasicAerospikePersistentEntity entity = new BasicAerospikePersistentEntity<>(typeInformation, defaultNameSpace); + BasicAerospikePersistentEntity entity = new BasicAerospikePersistentEntity<>(typeInformation); if (context != null) { entity.setEnvironment(context.getEnvironment()); } diff --git a/src/main/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntity.java b/src/main/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntity.java index e1875a290..b4ed4e733 100644 --- a/src/main/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntity.java +++ b/src/main/java/org/springframework/data/aerospike/mapping/AerospikePersistentEntity.java @@ -25,11 +25,6 @@ */ public interface AerospikePersistentEntity extends PersistentEntity { - /** - * Returns the name of the set the {@link PersistentEntity} shall be stored in. - */ - String getNamespace(); - String getSetName(); int getExpiration(); diff --git a/src/main/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntity.java b/src/main/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntity.java index 585bbf1fc..2a6b617de 100644 --- a/src/main/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntity.java +++ b/src/main/java/org/springframework/data/aerospike/mapping/BasicAerospikePersistentEntity.java @@ -34,25 +34,20 @@ public class BasicAerospikePersistentEntity extends BasicPersistentEntity setName; private final Lazy expiration; private final Lazy isTouchOnRead; - /** * Creates a new {@link BasicAerospikePersistentEntity} - * using a given {@link TypeInformation} and a default namespace. + * using a given {@link TypeInformation}. * * @param information must not be {@literal null}. - * @param defaultNameSpace The default namespace. */ - public BasicAerospikePersistentEntity(TypeInformation information, String defaultNameSpace) { + public BasicAerospikePersistentEntity(TypeInformation information) { super(information); - this.defaultNameSpace = defaultNameSpace; this.setName = Lazy.of(() -> { Class type = getType(); Document annotation = type.getAnnotation(Document.class); @@ -93,11 +88,6 @@ public void addPersistentProperty(AerospikePersistentProperty property) { } } - @Override - public String getNamespace() { - return defaultNameSpace; - } - /* * (non-Javadoc) * @see org.springframework.data.aerospike.mapping.AerospikePersistentEntity#getSetName() diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/AerospikeRepositoryConfigurationExtension.java b/src/main/java/org/springframework/data/aerospike/repository/config/AerospikeRepositoryConfigurationExtension.java index 2b24a6031..4b11cb943 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/AerospikeRepositoryConfigurationExtension.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/AerospikeRepositoryConfigurationExtension.java @@ -42,11 +42,6 @@ protected String getModulePrefix() { return "aerospike"; } - @Override - protected String getDefaultKeyValueTemplateRef() { - return "aerospikeTemplate"; - } - @Override public String getRepositoryFactoryBeanClassName() { return AerospikeRepositoryFactoryBean.class.getName(); diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java b/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java index 01f48db2b..047d077cb 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java @@ -19,10 +19,10 @@ import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.type.AnnotationMetadata; import org.springframework.data.aerospike.repository.query.AerospikeQueryCreator; -import org.springframework.data.keyvalue.repository.config.KeyValueRepositoryConfigurationExtension; import org.springframework.data.keyvalue.repository.config.QueryCreatorType; import org.springframework.data.keyvalue.repository.query.SpelQueryCreator; import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource; +import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport; import java.util.Map; @@ -30,14 +30,17 @@ * @author Oliver Gierke * @author Igor Ermolenko */ -public abstract class BaseAerospikeRepositoryConfigurationExtension extends KeyValueRepositoryConfigurationExtension { +public abstract class BaseAerospikeRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport { + + protected static final String MAPPING_CONTEXT_BEAN_NAME = "aerospikeMappingContext"; + protected static final String AEROSPIKE_TEMPLATE_BEAN_REF_ATTRIBUTE = "aerospikeTemplateRef"; @Override public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) { AnnotationAttributes attributes = config.getAttributes(); - builder.addPropertyReference("operations", attributes.getString(KEY_VALUE_TEMPLATE_BEAN_REF_ATTRIBUTE)); + builder.addPropertyReference("operations", attributes.getString(AEROSPIKE_TEMPLATE_BEAN_REF_ATTRIBUTE)); builder.addPropertyValue("queryCreator", getQueryCreatorType(config)); builder.addPropertyReference("mappingContext", MAPPING_CONTEXT_BEAN_NAME); } diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java b/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java index 5e43e823b..92e5c6849 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java @@ -20,7 +20,7 @@ import org.springframework.context.annotation.Import; import org.springframework.data.aerospike.repository.support.AerospikeRepositoryFactoryBean; import org.springframework.data.aerospike.repository.support.SimpleAerospikeRepository; -import org.springframework.data.keyvalue.core.KeyValueOperations; +import org.springframework.data.aerospike.core.AerospikeOperations; import org.springframework.data.repository.query.QueryLookupStrategy; import org.springframework.data.repository.query.QueryLookupStrategy.Key; @@ -101,9 +101,9 @@ Class repositoryBaseClass() default SimpleAerospikeRepository.class; /** - * Configures the name of the {@link KeyValueOperations} bean to be used with the repositories detected. + * Configures the name of the {@link AerospikeOperations} bean to be used with the repositories detected. */ - String keyValueTemplateRef() default "aerospikeTemplate"; + String aerospikeTemplateRef() default "aerospikeTemplate"; /** * Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java b/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java index a995c6ff7..3ed6ebef9 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java @@ -20,7 +20,7 @@ import org.springframework.context.annotation.Import; import org.springframework.data.aerospike.repository.support.ReactiveAerospikeRepositoryFactoryBean; import org.springframework.data.aerospike.repository.support.SimpleReactiveAerospikeRepository; -import org.springframework.data.keyvalue.core.KeyValueOperations; +import org.springframework.data.aerospike.core.ReactiveAerospikeOperations; import org.springframework.data.repository.query.QueryLookupStrategy; import org.springframework.data.repository.query.QueryLookupStrategy.Key; @@ -101,9 +101,9 @@ Class repositoryBaseClass() default SimpleReactiveAerospikeRepository.class; /** - * Configures the name of the {@link KeyValueOperations} bean to be used with the repositories detected. + * Configures the name of the {@link ReactiveAerospikeOperations} bean to be used with the repositories detected. */ - String keyValueTemplateRef() default "reactiveAerospikeTemplate"; + String aerospikeTemplateRef() default "reactiveAerospikeTemplate"; /** * Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/ReactiveAerospikeRepositoryConfigurationExtension.java b/src/main/java/org/springframework/data/aerospike/repository/config/ReactiveAerospikeRepositoryConfigurationExtension.java index c8ff59746..3e47441ae 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/ReactiveAerospikeRepositoryConfigurationExtension.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/ReactiveAerospikeRepositoryConfigurationExtension.java @@ -42,11 +42,6 @@ protected String getModulePrefix() { return "reactive-aerospike"; } - @Override - protected String getDefaultKeyValueTemplateRef() { - return "reactiveAerospikeTemplate"; - } - @Override public String getRepositoryFactoryBeanClassName() { return ReactiveAerospikeRepositoryFactoryBean.class.getName(); diff --git a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterDeprecatedTest.java b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterDeprecatedTest.java index e1fa26ecf..5e715669d 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterDeprecatedTest.java +++ b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterDeprecatedTest.java @@ -90,7 +90,7 @@ public void convertsAddressCorrectlyToAerospikeData() { address.city = "New York"; address.street = "Broadway"; - AerospikeWriteData dbObject = AerospikeWriteData.forWrite(); + AerospikeWriteData dbObject = AerospikeWriteData.forWrite(key.namespace); converter.write(address, dbObject); Collection bins = dbObject.getBins(); @@ -126,7 +126,7 @@ public void writesMapTypeCorrectly() { foo.map = Collections.singletonMap(Locale.US, "Biff"); - AerospikeWriteData dbObject = AerospikeWriteData.forWrite(); + AerospikeWriteData dbObject = AerospikeWriteData.forWrite(key.namespace); converter.write(foo, dbObject); Object object = getBinValue("map", dbObject.getBins()); @@ -138,7 +138,7 @@ public void writesEnumsCorrectly() { ClassWithEnumProperty value = new ClassWithEnumProperty(); value.sampleEnum = SampleEnum.FIRST; - AerospikeWriteData result = AerospikeWriteData.forWrite(); + AerospikeWriteData result = AerospikeWriteData.forWrite(key.namespace); converter.write(value, result); Object object = getBinValue("sampleEnum", result.getBins()); @@ -153,7 +153,7 @@ public void writesEnumCollectionCorrectly() { ClassWithEnumProperty value = new ClassWithEnumProperty(); value.enums = Arrays.asList(SampleEnum.FIRST); - AerospikeWriteData result = AerospikeWriteData.forWrite(); + AerospikeWriteData result = AerospikeWriteData.forWrite(key.namespace); converter.write(value, result); Object object = getBinValue("enums", result.getBins()); @@ -203,7 +203,7 @@ public void considersFieldNameAnnotationWhenWriting() { person.id = "oliver-01"; person.firstname = "Oliver"; - AerospikeWriteData dbObject = AerospikeWriteData.forWrite(); + AerospikeWriteData dbObject = AerospikeWriteData.forWrite(key.namespace); converter.write(person, dbObject); @@ -239,7 +239,7 @@ public void readsEmptySetsCorrectly() { person.id = "oliver-02"; person.addresses = Collections.emptySet(); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(key.namespace); converter.write(person, forWrite); diff --git a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTest.java b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTest.java index 6c623e1ee..c2fe2c802 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTest.java +++ b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTest.java @@ -67,7 +67,7 @@ public class MappingAerospikeConverterTest extends BaseMappingAerospikeConverter public void readsCollectionOfObjectsToSetByDefault() { CollectionOfObjects object = new CollectionOfObjects("my-id", list(new Person(null, set(new SampleClasses.Address(new SampleClasses.Street("Zarichna", 1), 202))))); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(object, forWrite); @@ -110,7 +110,7 @@ public void shouldWriteAndReadUsingCustomConverter() { MappingAerospikeConverter converter = getMappingAerospikeConverter(new UserToAerospikeWriteDataConverter(), new AerospikeReadDataToUserConverter()); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); User user = new User(678, new Name("Nastya", "Smirnova"), null); converter.write(user, forWrite); @@ -130,7 +130,7 @@ public void shouldWriteAndReadIfTypeKeyIsNull() { MappingAerospikeConverter converter = getMappingAerospikeConverter(new AerospikeTypeAliasAccessor(null)); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); User user = new User(678L, null, null); converter.write(user, forWrite); @@ -148,7 +148,7 @@ public void shouldWriteAndReadIfTypeKeyIsNull() { @Test public void shouldWriteExpirationValue() { Person person = new Person("personId", Collections.emptySet()); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(person, forWrite); @@ -189,7 +189,7 @@ public void shouldWriteUnixTimeExpirationFieldValue() { DateTime unixTimeExpiration = DateTime.now().plusSeconds(EXPIRATION_ONE_MINUTE); DocumentWithUnixTimeExpiration document = new DocumentWithUnixTimeExpiration("docId", unixTimeExpiration); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(document, forWrite); assertThat(forWrite.getExpiration()).isIn(EXPIRATION_ONE_MINUTE, EXPIRATION_ONE_MINUTE - 1); @@ -200,7 +200,7 @@ public void shouldFailWithExpirationFromThePast() { DateTime expirationFromThePast = DateTime.now().minusSeconds(EXPIRATION_ONE_MINUTE); DocumentWithUnixTimeExpiration document = new DocumentWithUnixTimeExpiration("docId", expirationFromThePast); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); assertThatThrownBy(() -> converter.write(document, forWrite)) .isInstanceOf(IllegalArgumentException.class) @@ -210,7 +210,7 @@ public void shouldFailWithExpirationFromThePast() { @Test public void shouldWriteExpirationFieldValue() { DocumentWithExpirationAnnotation document = new DocumentWithExpirationAnnotation("docId", EXPIRATION_ONE_SECOND); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(document, forWrite); @@ -220,7 +220,7 @@ public void shouldWriteExpirationFieldValue() { @Test public void shouldNotSaveExpirationFieldAsBin() { DocumentWithExpirationAnnotation document = new DocumentWithExpirationAnnotation("docId", EXPIRATION_ONE_SECOND); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(document, forWrite); @@ -230,7 +230,7 @@ public void shouldNotSaveExpirationFieldAsBin() { @Test public void shouldFailWithNullExpirationFieldValue() { DocumentWithExpirationAnnotation document = new DocumentWithExpirationAnnotation("docId", null); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); assertThatThrownBy(() -> converter.write(document, forWrite)) .isInstanceOf(IllegalArgumentException.class) @@ -240,7 +240,7 @@ public void shouldFailWithNullExpirationFieldValue() { @Test public void shouldNotFailWithNeverExpirePolicy() { DocumentWithExpirationAnnotation document = new DocumentWithExpirationAnnotation("docId", NEVER_EXPIRE); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(document, forWrite); @@ -250,7 +250,7 @@ public void shouldNotFailWithNeverExpirePolicy() { @Test public void shouldNotFailWithDoNotUpdateExpirePolicy() { DocumentWithExpirationAnnotation document = new DocumentWithExpirationAnnotation("docId", DO_NOT_UPDATE_EXPIRATION); - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(document, forWrite); @@ -283,7 +283,7 @@ public void shouldReadExpirationForDocumentWithPersistenceConstructor() { @Test public void shouldNotWriteVersionToBins() { - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(new VersionedClass("id", "data", 42L), forWrite); assertThat(forWrite.getBins()).containsOnly( diff --git a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTest.java b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTest.java index 1642c2364..32f226f87 100644 --- a/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTest.java +++ b/src/test/java/org/springframework/data/aerospike/convert/MappingAerospikeConverterTypesTest.java @@ -428,7 +428,7 @@ private void assertWriteAndRead(T object, Object expectedUserKey, Bin... expectedBins) { - AerospikeWriteData forWrite = AerospikeWriteData.forWrite(); + AerospikeWriteData forWrite = AerospikeWriteData.forWrite(NAMESPACE); converter.write(object, forWrite);