The KeyValueTemplate
is a specialization of Template
to work with Key-value databases. Remember that this kind of database primarily works with the key. Thus, the select method from the Template might return UnsupportedOperationException
.
@Inject
KeyValueTemplate template;
...
User user = new User();
user.setNickname("ada");
user.setAge(10);
user.setName("Ada Lovelace");
List<User> users = Collections.singletonList(user);
template.put(user);
template.put(users);
Optional<Person> ada = template.get("ada", Person.class);
Iterable<Person> usersFound = template.get(Collections.singletonList("ada"), Person.class);
Warning
|
In key-value templates, both the @Entity and @Id annotations are required. The @Id identifies the key, and the whole entity will be the value. The API won’t cover how the value persists this entity.
|
@Inject
private KeyValueTemplate template;