Document
DocumentTemplate template=..;
List<Movie> movies = template.query("select * from Movie");
PreparedStatement preparedStatement = template.prepare("select * from Person where name = @name");
preparedStatement.bind("name", "Ada");
DocumentTemplateAsync template=..;
Consumer<List<Movie>> callback = l ->{};
template.query("select * from Movie", callback);
Column
ColumnTemplate template=..;
List<Movie> movies = template.query("select * from Movie");
PreparedStatement preparedStatement = template.prepare("select * from Person where name = @name");
preparedStatement.bind("name", "Ada");
ColumnTemplateAsync template=..;
Consumer<List<Movie>> callback = l ->{};
template.query("select * from Movie", callback);
Graph
GraphTemplate template = ...;
Optional<Person> person = template.singleResult("g.V().hasLabel('Person')");
GraphTemplate tempalte = ...;
PreparedStatement prepare = tempalte.prepare("g.V().hasLabel(param)");
prepare.bind("param", "Person");
List<Person> people = prepare.getResultList();
Key-Value
KeyValueTemplate template=...;
Optional<Person> person = template.getSingleResult("get id", Person.class);
KeyValueTemplate template=...;
PreparedStatement statement = template.prepare("get @id", Person.class);
statement.bind("id", 12);
List<Person> resultList = statement.getResultList();
Repository
interface PersonRepository extends Repository<Person, Long> {
@Query("g.V().hasLabel('Person').toList()")
List<Person> findByQuery();
@Query("g.V().hasLabel('Person').has('name', name).toList()")
List<Person> findByQuery(@Param("name") String name);
}
private PersonRepository repository =//needs repository to graph
personRepository.findByQuery("Ada");
interface PersonRepository extends Repository<Person, Long> {
@Query("g.V().hasLabel('Person').toList()")
List<Person> findByQuery();
@Query("g.V().hasLabel('Person').has('name', name).toList()")
List<Person> findByQuery(@Param("name") String name);
}
private PersonRepository repository =//needs repository to graph
personRepository.findByQuery("Ada");
interface PersonRepository extends R* epository<Person, Long> {
@Query("select * from Person")
Optional<Person> findByQuery();
@Query("select * from Person where id = @id")
Optional<Person> findByQuery(@Param("id") String id);
}
private PersonRepository repository =//needs repository either document or column
personRepository.findByQuery("Ada");
interface UserRepository extends Repository<User, String> {
Optional<User> findByName(String name);
@Query("get \"12\"")
Optional<User> findByQuery();
@Query("get @id")
Optional<User> findByQuery(@Param("id") String id);
}
private UserRepository repository =//needs repository key-value
- Eclipse JNoSQL does not create a query Graph; it uses Gremlin from Apache Tinkerpop.
- There isn't a single query to all kinds of NoSQL, there is a query to each NoSQL, and Query annotation won't do parser a universal question it will run from the implementation. E.g., The Query annotation might return an error if a developer writes a key-value query at the Query annotation in a Repository interface and then try to run in a Graph implementation, that will run as a gremlin, thereby a syntax error.