Created
April 9, 2015 16:01
-
-
Save dalmat36/73d2b93d026b4cb237de to your computer and use it in GitHub Desktop.
This code snippet creates and abstract indexed collection handler. This enables you to use Commons DBUtils to return a result from a database as a CQEngine indexed collection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class AbstractIndexedCollectionHandler<T> implements ResultSetHandler<IndexedCollection<T>> { | |
| public IndexedCollection<T> handle(ResultSet rs) throws SQLException { | |
| IndexedCollection<T> rows = CQEngine.newInstance(); | |
| while (rs.next()) { | |
| rows.add(this.handleRow(rs)); | |
| } | |
| return rows; | |
| } | |
| protected abstract T handleRow(ResultSet rs) throws SQLException; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment