Author: tv
Date: Sun Dec 9 16:27:40 2018
New Revision: 1848528
URL: http://svn.apache.org/viewvc?rev=1848528&view=rev
Log:
TORQUE-354: Add doSelectAsStream() to BasePeerImpl
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java?rev=1848528&r1=1848527&r2=1848528&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
Sun Dec 9 16:27:40 2018
@@ -830,6 +830,38 @@ public class BasePeerImpl<T> implements
}
/**
+ * Selects objects from a database
+ * within a transaction.
+ * This method returns a stream that <b>must</b> be closed after use.
+ * All resources used by this method will be closed when the stream is
+ * closed.
+ *
+ * @param criteria object used to create the SELECT statement.
+ * @param connection the connection to use, not null.
+ *
+ * @return The results of the query as a Stream, not null.
+ *
+ * @throws TorqueException Any exceptions caught during processing will be
+ * rethrown wrapped into a TorqueException.
+ */
+ public Stream<T> doSelectAsStream(
+ final Criteria criteria,
+ final Connection connection)
+ throws TorqueException
+ {
+ if (criteria.getSelectColumns().size() == 0)
+ {
+ addSelectColumns(criteria);
+ }
+ setDbName(criteria);
+
+ return doSelectAsStream(
+ criteria,
+ getRecordMapper(),
+ connection);
+ }
+
+ /**
* Selects at most one object from a database.
*
* @param criteria object used to create the SELECT statement.
@@ -956,6 +988,30 @@ public class BasePeerImpl<T> implements
/**
* Selects rows from a database an maps them to objects.
+ * This method returns a stream that <b>must</b> be closed after use.
+ * All resources used by this method will be closed when the stream is
+ * closed.
+ *
+ * @param query the SQL Query to execute, not null.
+ * @param connection the database connection, not null.
+ *
+ * @return The results of the query as a Stream, not null.
+ *
+ * @throws TorqueException if querying the database fails.
+ */
+ public Stream<T> doSelectAsStream(
+ final String query,
+ final Connection connection)
+ throws TorqueException
+ {
+ return doSelectAsStream(
+ query,
+ getRecordMapper(),
+ connection);
+ }
+
+ /**
+ * Selects rows from a database an maps them to objects.
*
* @param query the sql query to execute, not null.
* @param mapper The mapper creating the objects from the resultSet,
@@ -1023,7 +1079,7 @@ public class BasePeerImpl<T> implements
* not null.
* @param connection the database connection, not null.
*
- * @return The results of the query, not null.
+ * @return The results of the query as a Stream, not null.
*
* @throws TorqueException if querying the database fails.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]