Skip to content

Introduction of annotation which is auto-populated with generationId: @AerospikeGenerationId #181

@51stDimension

Description

@51stDimension

Description
This issue proposes the introduction of a new annotation in java-aeromapper called @AerospikeGenerationId. This annotation will automatically map and populate the Aerospike record's generation ID into the annotated field when an entity is read from the database.

Use Case
Currently, Aerospike records include a metadata field called generation, which is useful for handling optimistic concurrency and versioning. However, this information is not automatically populated into mapped Java entities by Aeromapper.

With the proposed annotation, users can retrieve the generation number as part of the mapped entity without additional boilerplate.

@Getter
@Setter
@AerospikeRecord(namespace = "test", set = "testSet")
public class UserEntity extends BaseAerospikeEntity {

    @AerospikeKey
    private String userId;

    @AerospikeBin(name="frstNme")
    private String firstName;

    @AerospikeGeneration
    private int generationId;

    @AerospikeBin(name="lstNme")
    private String lastName;
}

Expected Behavior
When a record is fetched using Aeromapper:
The field annotated with @AerospikeGenerationId should automatically receive the value of the Aerospike record's generation count.
This should not require explicit mapping or manual population.

During the record-to-entity conversion, the mapper should check for fields annotated with @AerospikeGenerationId and set the value using Record.generation.
The annotation should be valid only on integer types (int, Integer).
There should be validation to ensure only one such field is present per class (similar to @AerospikeKey behavior).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions