Author: tv Date: Sun Dec 9 16:28:24 2018 New Revision: 1848529 URL: http://svn.apache.org/viewvc?rev=1848529&view=rev Log: TORQUE-354: Add doSelectAsStream() to Peers
Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm?rev=1848529&r1=1848528&r2=1848529&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm Sun Dec 9 16:28:24 2018 @@ -64,6 +64,30 @@ } /** + * Selects ${dbObjectClassName} 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 holding the transaction, 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 static Stream<${dbObjectClassName}> doSelectAsStream( + Criteria criteria, + Connection connection) + throws TorqueException + { + return ${peerImplGetter}().doSelectAsStream(criteria, connection); + } + + /** * Selects rows from a database an maps them to objects. * * @param criteria A Criteria specifying the records to select, not null. @@ -92,6 +116,7 @@ * not null. * * @return The results of the query, not null. + * * @throws TorqueException Error performing database query. */ public static <T> List<T> doSelect( @@ -109,6 +134,35 @@ /** * 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 criteria A Criteria specifying the records to select, not null. + * @param mapper The mapper creating the objects from the resultSet, + * not null. + * @param connection the database connection for selecting records, + * not null. + * + * @return The results of the query as a Stream, not null. + * + * @throws TorqueException Error performing database query. + */ + public static <T> Stream<T> doSelectAsStream( + Criteria criteria, + RecordMapper<T> mapper, + Connection connection) + throws TorqueException + { + return ${peerImplGetter}().doSelectAsStream( + criteria, + mapper, + 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, * not null. @@ -153,6 +207,34 @@ query, mapper, connection); + } + + /** + * 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 mapper The mapper creating the objects from the resultSet, + * 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 static <T> Stream<T> doSelectAsStream( + String query, + RecordMapper<T> mapper, + Connection connection) + throws TorqueException + { + return ${peerImplGetter}().doSelectAsStream( + query, + mapper, + connection); } /** Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm?rev=1848529&r1=1848528&r2=1848529&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm (original) +++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm Sun Dec 9 16:28:24 2018 @@ -38,6 +38,7 @@ import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org