|
23 | 23 | import java.util.stream.Stream; |
24 | 24 |
|
25 | 25 | /** |
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> |
27 | 31 | */ |
28 | 32 | public interface OrientDBTemplate extends DocumentTemplate { |
29 | 33 |
|
30 | 34 | /** |
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> |
32 | 45 | * |
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 |
37 | 51 | */ |
38 | 52 | <T> Stream<T> sql(String query, Object... params); |
39 | 53 |
|
40 | 54 | /** |
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> |
42 | 65 | * |
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 |
47 | 71 | */ |
48 | 72 | <T> Stream<T> sql(String query, Map<String, Object> params); |
| 73 | + |
49 | 74 | /** |
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> |
51 | 86 | * |
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 |
55 | 91 | */ |
56 | 92 | <T> void live(SelectQuery query, OrientDBLiveCallback<T> callBacks); |
57 | 93 |
|
58 | 94 | /** |
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> |
60 | 105 | * |
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 |
65 | 111 | */ |
66 | 112 | <T> void live(String query, OrientDBLiveCallback<T> callBacks, Object... params); |
67 | 113 | } |
0 commit comments