Package com.aerospike.mapper.annotations
Annotation Type AerospikeEmbed
@Retention(RUNTIME) @Target(FIELD) public @interface AerospikeEmbed
Bins marked with AerospikeEmbed will have the objects they reference embedded in the parent object, either as a list or a map
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AerospikeEmbed.EmbedType
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description AerospikeEmbed.EmbedType
elementType
The elementType is used for sub-elements.boolean
saveKey
Determine whether the key should be saved in the sub-object.AerospikeEmbed.EmbedType
type
-
Element Details
-
type
- Default:
- DEFAULT
-
elementType
AerospikeEmbed.EmbedType elementTypeThe elementType is used for sub-elements. For example, if there is:- Default:
- DEFAULT
-
saveKey
boolean saveKeyDetermine whether the key should be saved in the sub-object. This is used only for translating a list of objects in Java into a map of objects which contains a list. For example:public class Transaction { private String name; private int value; @AerospikeKey private long time; public Transaction() {} public Transaction(String name, int value, long time) { super(); this.name = name; this.value = value; this.time = time; } } ... @AerospikeEmbed(type = EmbedType.MAP, elementType = EmbedType.LIST) public List<Transaction> txns;
Assume elements have been inserted into the list as follows:
account.txns.add(new Transaction("details1", 100, 101)); account.txns.add(new Transaction("details2", 200, 99)); account.txns.add(new Transaction("details3", 300, 1010));
Since these elements are stored in a map, the AerospikeKey field (time in this case) will be the key to the map. By default, the key is then dropped from the list as it is not needed, resulting in:
KEY_ORDERED_MAP('{99:["details2", 200], 101:["details1", 100], 1010:["details3", 300]}')
If it is desired for the key to be part of the list as well, this value can be set to
true
:@AerospikeEmbed(type = EmbedType.MAP, elementType = EmbedType.LIST, saveKey = true) public List<Transaction> txns;
This would result in:
KEY_ORDERED_MAP('{99:["details2", 99, 200], 101:["details1", 101, 100], 1010:["details3", 1010, 300]}')
- Default:
- false
-