Skip to content

Commit 0065cca

Browse files
committed
feat: update documentation on orientdb template
Signed-off-by: Otavio Santana <[email protected]>
1 parent bd6f460 commit 0065cca

File tree

1 file changed

+66
-20
lines changed

1 file changed

+66
-20
lines changed

jnosql-orientdb/src/main/java/org/eclipse/jnosql/databases/orientdb/mapping/OrientDBTemplate.java

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,91 @@
2323
import java.util.stream.Stream;
2424

2525
/**
26-
* A {@link DocumentTemplate} to orientdb
26+
* A specialized {@link DocumentTemplate} for OrientDB.
27+
* <p>
28+
* This template provides methods for executing native SQL queries,
29+
* live queries, and queries with named parameters.
30+
* </p>
2731
*/
2832
public interface OrientDBTemplate extends DocumentTemplate {
2933

3034
/**
31-
* Find using OrientDB native query
35+
* Executes a native OrientDB SQL query.
36+
* <p>
37+
* This method allows running SQL queries with positional parameters.
38+
* Example usage:
39+
* <pre>
40+
* {@code
41+
* Stream<User> users = template.sql("SELECT FROM User WHERE age > ?", 30);
42+
* }
43+
* </pre>
44+
* </p>
3245
*
33-
* @param query the query
34-
* @param params the params
35-
* @return the query result
36-
* @throws NullPointerException when either query or params are null
46+
* @param <T> the expected result type
47+
* @param query the SQL query string
48+
* @param params optional positional parameters for the query
49+
* @return a stream of results matching the query
50+
* @throws NullPointerException if the query or params are null
3751
*/
3852
<T> Stream<T> sql(String query, Object... params);
3953

4054
/**
41-
* Find using OrientDB native query with map params
55+
* Executes a native OrientDB SQL query with named parameters.
56+
* <p>
57+
* Example usage:
58+
* <pre>
59+
* {@code
60+
* Map<String, Object> params = Map.of("age", 30);
61+
* Stream<User> users = template.sql("SELECT FROM User WHERE age > :age", params);
62+
* }
63+
* </pre>
64+
* </p>
4265
*
43-
* @param query the query
44-
* @param params the params
45-
* @return the query result
46-
* @throws NullPointerException when either query or params are null
66+
* @param <T> the expected result type
67+
* @param query the SQL query string
68+
* @param params a map of named parameters for the query
69+
* @return a stream of results matching the query
70+
* @throws NullPointerException if the query or params are null
4771
*/
4872
<T> Stream<T> sql(String query, Map<String, Object> params);
73+
4974
/**
50-
* Execute live query
75+
* Executes a live query in OrientDB.
76+
* <p>
77+
* A live query listens for real-time changes in the database and triggers callbacks
78+
* for each event that occurs (insert, update, delete).
79+
* Example usage:
80+
* <pre>
81+
* {@code
82+
* template.live(selectQuery, event -> System.out.println("Update: " + event));
83+
* }
84+
* </pre>
85+
* </p>
5186
*
52-
* @param query the query
53-
* @param callBacks callbacks for each operation
54-
* @throws NullPointerException when both query and callBack are null
87+
* @param <T> the expected result type
88+
* @param query the query definition using {@link SelectQuery}
89+
* @param callBacks callback to handle live query events
90+
* @throws NullPointerException if either query or callBacks is null
5591
*/
5692
<T> void live(SelectQuery query, OrientDBLiveCallback<T> callBacks);
5793

5894
/**
59-
* Execute live query
95+
* Executes a live query in OrientDB using a SQL string.
96+
* <p>
97+
* The query must include the "LIVE" keyword.
98+
* Example usage:
99+
* <pre>
100+
* {@code
101+
* template.live("LIVE SELECT FROM User", event -> System.out.println("User changed: " + event));
102+
* }
103+
* </pre>
104+
* </p>
60105
*
61-
* @param query the string query, you must add "live"
62-
* @param callBacks callbacks for each operation
63-
* @param params the params
64-
* @throws NullPointerException when both query, callBack are null
106+
* @param <T> the expected result type
107+
* @param query the SQL query string containing the "LIVE" keyword
108+
* @param callBacks callback to handle live query events
109+
* @param params optional positional parameters for the query
110+
* @throws NullPointerException if either query or callBacks is null
65111
*/
66112
<T> void live(String query, OrientDBLiveCallback<T> callBacks, Object... params);
67113
}

0 commit comments

Comments
 (0)