public List < Post > selectChildren ( final long parentId , final boolean withResolve ) throws SQLException { List < Post . Builder > builders = Lists . newArrayListWithExpectedSize ( 4 ) ; Connection conn = null ; PreparedStatement stmt = null ; ResultSet rs = null ; Timer . Context ctx = metrics . selectChildrenTimer . time ( ) ; try { conn = connectionSupplier . getConnection ( ) ; stmt = conn . prepareStatement ( selectChildrenSQL ) ; stmt . setLong ( 1 , parentId ) ; rs = stmt . executeQuery ( ) ; while ( rs . next ( ) ) { builders . add ( postFromResultSet ( rs ) ) ; } } finally { ctx . stop ( ) ; SQLUtil . closeQuietly ( conn , stmt , rs ) ; } List < Post > posts = Lists . newArrayListWithExpectedSize ( builders . size ( ) ) ; for ( Post . Builder builder : builders ) { if ( withResolve ) { posts . add ( resolve ( builder ) . build ( ) ) ; } else { posts . add ( builder . build ( ) ) ; } } return posts ; }
Gets all children for a post .