You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2008/09/30 15:09:12 UTC
svn commit: r700445 -
/labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java
Author: simoneg
Date: Tue Sep 30 06:09:12 2008
New Revision: 700445
URL: http://svn.apache.org/viewvc?rev=700445&view=rev
Log:
New methods to paginate results
Modified:
labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java
Modified: labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java?rev=700445&r1=700444&r2=700445&view=diff
==============================================================================
--- labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java (original)
+++ labs/magma/trunk/foundation-database/src/main/java/org/apache/magma/database/Database.java Tue Sep 30 06:09:12 2008
@@ -51,6 +51,21 @@
return null;
}
+
+ /**
+ * Executes a query returning all results. This is the same as calling
+ * {@link #query(Class, int, int, String, Object...)} with both
+ * start and page to zero.
+ * @param <T> The class of elements returned by the query
+ * @param clazz The class of elements returned by the query
+ * @param query The JPQL query, eventually without the "SELECT x FROM ClassName x" part, as stated above.
+ * @param params The params to replace in the query.
+ * @return A List of entities of the specified class, ordered as eventually specified in the query.
+ */
+ public <T> List<T> query(Class<T> clazz, String query, Object... params) {
+ return query(clazz, 0, 0, query, params);
+ }
+
/**
* Executes a query on a certain entity class.
* <p>
@@ -66,7 +81,7 @@
* <p>
* This simplifies the most frequent case, and also reduces the number of typos while increasing compile
* time checking. If a more complex where statement is needed, it's possible to start the query with
- * the "SELECT" keyword, in that case no modification to the string is done, and the
+ * the "SELECT" keyword, in that case no modification to the string is done.
* </p>
* <p>
* To make a query that does not fetch a specific entity, but for example calculates some different data,
@@ -77,11 +92,13 @@
* </p>
* @param <T> The class of elements returned by the query
* @param clazz The class of elements returned by the query
+ * @param from The index of the first result to return, or 0 to start from the first result
+ * @param page The number of results to return, or 0 to return all results
* @param query The JPQL query, eventually without the "SELECT x FROM ClassName x" part, as stated above.
* @param params The params to replace in the query.
* @return A List of entities of the specified class, ordered as eventually specified in the query.
*/
- public <T> List<T> query(Class<T> clazz, String query, Object... params) {
+ public <T> List<T> query(Class<T> clazz, int from, int page, String query, Object... params) {
return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org