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
Copy file name to clipboardExpand all lines: README.md
+20-10Lines changed: 20 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,7 @@ p.setSsn("123456789");
175
175
p.setAge(17);
176
176
177
177
AerospikeClient client = new AerospikeClient("aerospike hostname",3000);
178
-
AeroMapper mapper = new AeroMapper(client);
178
+
AeroMapper mapper = new AeroMapper.Builder(client).build();
179
179
mapper.save(p);
180
180
```
181
181
@@ -252,7 +252,7 @@ In this case the `forAll()` would apply to A,B,C, the `forThisOrChildrenOf` woul
252
252
253
253
Note that each operation can also optionally take a policy if it is desired to change any of the policy settings on the fly. The explicitly provided policy will override any other settings, such as `durableDelete` on the `@AerospikeRecord`
254
254
255
-
if it is desired to change one part of a policy but keep the rest as the defaults set up with these policies, the appropriate policy can be read with `getReadPolicy`, `getWritePolicy`, `getBatchPolicy`, `getScanPolicy` and `getQueryPolicy` methods on the AeroMapper. For example, if we needed a policy which was preiously set up on a Customer class but needed to change the `durableDelete` property, we could do
255
+
If it is desired to change one part of a policy but keep the rest as the defaults set up with these policies, the appropriate policy can be read with `getReadPolicy`, `getWritePolicy`, `getBatchPolicy`, `getScanPolicy` and `getQueryPolicy` methods on the AeroMapper. For example, if we need a policy which was previously set up on a Customer class but need to change the `durableDelete` property, we could do
@@ -305,7 +305,10 @@ public class ConstructedClass {
305
305
public final String name;
306
306
public final Date date;
307
307
308
-
public ConstructedClass(@ParamFrom("id") int id, @ParamFrom("age") int age, @ParamFrom("name") String name, @ParamFrom("date")Date date) {
308
+
public ConstructedClass(@ParamFrom("id") int id,
309
+
@ParamFrom("age") int age,
310
+
@ParamFrom("name") String name,
311
+
@ParamFrom("date") Date date) {
309
312
super();
310
313
this.id = id;
311
314
this.age = age;
@@ -348,7 +351,9 @@ public class ConstructedClass2 {
348
351
}
349
352
```
350
353
351
-
Whilst these examples show only final fields being set, this is not a requirement.
354
+
When an instance of the ConstructedClass2 is read from the database, the constructor will be invoked and `a` and `id` set via the constructor, then `b` and `c` will be set by direct field access.
355
+
356
+
Note that whilst these examples show only final fields being set, this is not a requirement. The constructor can set any or all fields.
352
357
353
358
If there are multiple constructors on the class, the one to be used by the AeroMapper should be annotated with @AerospikeConstructor:
354
359
@@ -374,9 +379,9 @@ public class ConstructedClass2 {
374
379
}
375
380
```
376
381
377
-
In this case, the 3 argument constructor will be used. Note that you must annotate the desired constructor with @AerospikeConstructor on any class with multiple constructors, irrespective of how many of those constructors have the @ParamFrom annotations on their arguments. It is only allowed to have one constructor so annotated.
382
+
In this case, the 3 argument constructor will be used. Note that you must annotate the desired constructor with @AerospikeConstructor on any class with multiple constructors, irrespective of how many of those constructors have the @ParamFrom annotations on their arguments. If more than 1 constructor is annotated with @AerospikeConstructor on a class an exception will be thrown the first time the mapper sees that class.
378
383
379
-
If no constructor is annotated with @AerospikeConstructor, the default no-argument constructor will be used. If there is no no-argument constructor and no @AerospikeConstructor annotated constructor has been declared, an exception will be thrown when the class is first used.
384
+
If no constructor is annotated with @AerospikeConstructor, the default no-argument constructor will be used. If there is no no-argument constructor but only one constructor on the class, that constructor will be used. If there is no default constructor and multiple other constructors but no @AerospikeConstructor annotated constructor has been declared, an exception will be thrown when the class is first used.
380
385
381
386
---
382
387
@@ -596,11 +601,12 @@ Here are how standard Java types are mapped to Aerospike types:
596
601
| Map<?,?> | Map |
597
602
| Object Reference (@AerospikeRecord) | List or Map |
598
603
599
-
These types are built into the converter. However, if you wish to change them, you can use a (Custom Object Converter)]custom-object-converter]. For example, if you want Dates stored in the database as a string, you could do:
604
+
These types are built into the converter. However, if you wish to change them, you can use a (Custom Object Converter)[custom-object-converter]. For example, if you want Dates stored in the database as a string, you could do:
600
605
601
606
```java
602
607
public static class DateConverter {
603
-
private static final ThreadLocal<SimpleDateFormat> dateFormatter = ThreadLocal.withInitial(() -> new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS zzzZ"));
608
+
private static final ThreadLocal<SimpleDateFormat> dateFormatter = ThreadLocal.withInitial(() ->
609
+
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS zzzZ"));
604
610
@ToAerospike
605
611
public String toAerospike(Date date) {
606
612
if (date == null) {
@@ -1187,7 +1193,9 @@ This gets saved in the database as:
0 commit comments