Skip to content

Commit 40edf14

Browse files
authored
Merge pull request #312 from eclipse-jnosql/documentation-database
Enhance documentation
2 parents d64e42f + 7ca340f commit 40edf14

File tree

47 files changed

+664
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+664
-538
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
1919
- Update Couchbase client 3.7.6
2020
- Update DynamoDB driver 2.29.45
2121
- Update ArangoDb driver to 7.17.0
22+
- At repositories params, use the Param annotation from Jakarta Data API.
2223

2324
=== Fixed
2425

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/AQL.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,33 @@
2020
import java.lang.annotation.Target;
2121

2222
/**
23-
* To a dynamic query on ArangoDBRepository and ArangoDBRepositoryAsync interfaces.
23+
* Annotation to define a dynamic AQL (ArangoDB Query Language) query for methods
24+
* in the {@link ArangoDBRepository} interface.
25+
* This annotation enables executing custom AQL queries directly from repository methods,
26+
* similar to how queries are defined in other JNoSQL repositories.
27+
*
28+
* Example usage:
29+
* <pre>{@code
30+
* @AQL("FOR p IN Person RETURN p")
31+
* List<Person> findAll();
32+
* }</pre>
33+
*
34+
*Parameterized query:
35+
* <pre>{@code
36+
* @AQL("FOR p IN Person FILTER p.name == @name RETURN p")
37+
* List<Person> findByName(@Param("name") String name);
38+
* }</pre>
39+
*
40+
* @see ArangoDBRepository
2441
*/
2542
@Retention(RetentionPolicy.RUNTIME)
2643
@Target(ElementType.METHOD)
2744
public @interface AQL {
2845

46+
/**
47+
* The AQL query string to be executed.
48+
*
49+
* @return the AQL query
50+
*/
2951
String value();
3052
}

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBDocumentRepositoryProxy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.eclipse.jnosql.mapping.core.query.AbstractRepository;
2020
import org.eclipse.jnosql.mapping.core.repository.DynamicReturn;
2121
import org.eclipse.jnosql.mapping.document.DocumentTemplate;
22+
import org.eclipse.jnosql.mapping.driver.ParamUtil;
2223
import org.eclipse.jnosql.mapping.metadata.EntitiesMetadata;
2324
import org.eclipse.jnosql.mapping.metadata.EntityMetadata;
2425
import org.eclipse.jnosql.mapping.semistructured.query.AbstractSemiStructuredRepositoryProxy;
@@ -93,7 +94,7 @@ public Object invoke(Object instance, Method method, Object[] args) throws Throw
9394
AQL aql = method.getAnnotation(AQL.class);
9495
if (Objects.nonNull(aql)) {
9596
Stream<T> result;
96-
Map<String, Object> params = ParamUtil.getParams(args, method);
97+
Map<String, Object> params = ParamUtil.INSTANCE.getParams(args, method);
9798
if (params.isEmpty()) {
9899
result = template.aql(aql.value(), emptyMap());
99100
} else {

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBRepository.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,25 @@
1919

2020

2121
/**
22-
* The arangodb {@link NoSQLRepository}
22+
* A repository interface for ArangoDB, extending the generic {@link NoSQLRepository}.
23+
* This repository supports executing custom AQL queries via the {@link AQL} annotation.
24+
*
25+
* Example usage:
26+
* <pre>{@code
27+
* @Repository
28+
* public interface PersonRepository extends ArangoDBRepository<Person, String> {
29+
*
30+
* @AQL("FOR p IN Person RETURN p")
31+
* List<Person> findAll();
32+
*
33+
* @AQL("FOR p IN Person FILTER p.name == @name RETURN p")
34+
* List<Person> findByName(@Param("name") String name);
35+
* }
36+
* }</pre>
37+
*
2338
* @param <T> the entity type
24-
* @param <K> the id entity type
39+
* @param <K> the entity ID type
40+
* @see AQL
2541
*/
2642
public interface ArangoDBRepository<T, K> extends NoSQLRepository<T, K> {
2743
}

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBTemplate.java

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,62 +21,71 @@
2121
import java.util.Map;
2222
import java.util.stream.Stream;
2323
/**
24-
* A template specialization for ArangoDB that includes capabilities for executing ArangoDB query language, AQL.
25-
* This template extends {@link DocumentTemplate} and provides methods for executing AQL queries with various
26-
* options.
24+
* A specialized {@link DocumentTemplate} for ArangoDB, providing methods to execute
25+
* queries using the ArangoDB Query Language (AQL).
26+
*
27+
* This template allows executing AQL queries with named parameters and supports
28+
* result serialization either through Eclipse JNoSQL or directly via ArangoDB.
2729
*/
2830
public interface ArangoDBTemplate extends DocumentTemplate {
2931

3032
/**
3133
* Executes an ArangoDB query using the ArangoDB Query Language (AQL).
3234
*
33-
* <p>Example query: {@code FOR u IN users FILTER u.status == @status RETURN u}</p>
35+
* <p>Example query:</p>
36+
* <pre>{@code
37+
* FOR u IN users FILTER u.status == @status RETURN u
38+
* }</pre>
3439
*
35-
* <p>The conversion from the query result to entities will happen at the Eclipse JNoSQL side.
36-
* It will utilize and consider all the annotations supported by Eclipse JNoSQL.</p>
40+
* <p>The conversion of query results to entity objects is handled by Eclipse JNoSQL,
41+
* applying all supported annotations.</p>
3742
*
38-
* @param <T> the entity class
39-
* @param query the AQL query
40-
* @param params the named parameters for the query
43+
* @param <T> the entity type
44+
* @param query the AQL query string
45+
* @param params a map containing named parameters for the query
4146
* @return a {@link Stream} of entities representing the query result
42-
* @throws NullPointerException when either the query or params are null
47+
* @throws NullPointerException if {@code query} or {@code params} is {@code null}
4348
*/
4449
<T> Stream<T> aql(String query, Map<String, Object> params);
4550

4651
/**
47-
* Executes an ArangoDB query using the ArangoDB Query Language (AQL).
52+
* Executes an ArangoDB query using AQL with direct serialization via ArangoDB.
4853
*
49-
* <p>Example query: {@code FOR u IN users FILTER u.status == @status RETURN u}</p>
54+
* <p>Example query:</p>
55+
* <pre>{@code
56+
* FOR u IN users FILTER u.status == @status RETURN u
57+
* }</pre>
5058
*
51-
* <p>The serialization of the query result will happen at the ArangoDB side using
52-
* {@link com.arangodb.ArangoDatabase#query(String, Class)}. This serialization does not have any converter support
53-
* at the mapper side,
54-
* thus it will ignore any annotations that Eclipse JNoSQL has.</p>
59+
* <p>The serialization of query results is performed directly by ArangoDB using
60+
* {@link com.arangodb.ArangoDatabase#query(String, Class)}, bypassing Eclipse JNoSQL
61+
* converters. Consequently, annotations supported by Eclipse JNoSQL are ignored.</p>
5562
*
56-
* @param query the AQL query
57-
* @param params the named parameters for the query
58-
* @param type the type of the result
59-
* @param <T> the type
60-
* @return a {@link Stream} of the specified type representing the query result
61-
* @throws NullPointerException when either the query or params are null
63+
* @param <T> the expected result type
64+
* @param query the AQL query string
65+
* @param params a map containing named parameters for the query
66+
* @param type the target class for result serialization
67+
* @return a {@link Stream} of results of type {@code T}
68+
* @throws NullPointerException if {@code query}, {@code params}, or {@code type} is {@code null}
6269
*/
6370
<T> Stream<T> aql(String query, Map<String, Object> params, Class<T> type);
6471

6572
/**
66-
* Executes an ArangoDB query using the ArangoDB Query Language (AQL) with an empty parameter map.
73+
* Executes an ArangoDB query using AQL with an empty parameter map.
6774
*
68-
* <p>Example query: {@code FOR u IN users FILTER u.status == @status RETURN u}</p>
75+
* <p>Example query:</p>
76+
* <pre>{@code
77+
* FOR u IN users FILTER u.status == @status RETURN u
78+
* }</pre>
6979
*
70-
* <p>The serialization of the query result will happen at the ArangoDB side using
71-
* {@link com.arangodb.ArangoDatabase#query(String, Class)}. This serialization does not have any converter support
72-
* at the mapper side,
73-
* thus it will ignore any annotations that Eclipse JNoSQL has.</p>
80+
* <p>The serialization of query results is performed directly by ArangoDB using
81+
* {@link com.arangodb.ArangoDatabase#query(String, Class)}. This means that
82+
* Eclipse JNoSQL annotations will not be considered.</p>
7483
*
75-
* @param query the AQL query
76-
* @param type the type of the result
77-
* @param <T> the type
78-
* @return a {@link Stream} of the specified type representing the query result
79-
* @throws NullPointerException when either the query or type are null
84+
* @param <T> the expected result type
85+
* @param query the AQL query string
86+
* @param type the target class for result serialization
87+
* @return a {@link Stream} of results of type {@code T}
88+
* @throws NullPointerException if {@code query} or {@code type} is {@code null}
8089
*/
8190
<T> Stream<T> aql(String query, Class<T> type);
8291
}

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/Param.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ParamUtil.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBDocumentRepositoryProxyTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package org.eclipse.jnosql.databases.arangodb.mapping;
1616

17+
import jakarta.data.repository.Param;
1718
import jakarta.inject.Inject;
1819
import org.assertj.core.api.Assertions;
1920
import org.eclipse.jnosql.mapping.core.Converters;

jnosql-cassandra/src/main/java/org/eclipse/jnosql/databases/cassandra/mapping/CQL.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@
2020
import java.lang.annotation.Target;
2121

2222
/**
23-
* Annotation used to define a dynamic CQL query method in CassandraRepository and CassandraRepositoryAsync interfaces.
23+
* Annotation used to define a dynamic CQL query method in {@link CassandraRepository}.
24+
* Methods annotated with {@code @CQL} allow the execution of custom Cassandra Query Language (CQL) statements
25+
* within repository interfaces.
26+
* Example usage:
27+
* <pre>{@code
28+
* @CQL("SELECT * FROM users WHERE username = :username")
29+
* List<User> findByUsername(@Param("username") String username);
30+
* }</pre>
2431
*/
2532
@Retention(RetentionPolicy.RUNTIME)
2633
@Target(ElementType.METHOD)
2734
public @interface CQL {
2835

2936
/**
30-
* The CQL query string.
37+
* The CQL query string to be executed.
3138
*
3239
* @return the CQL query string
3340
*/

jnosql-cassandra/src/main/java/org/eclipse/jnosql/databases/cassandra/mapping/CQLObjectUtil.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)