問合せの逆方向の1行ずつの処理

ビュー・オブジェクトのprevious()メソッドをコールして、ビュー・オブジェクトの問合せを1行ずつ逆方向に処理します。このメソッドでは、ビュー・オブジェクトの現在の行が1行ずつ逆方向に移動されて、新しい現在の行が返されます。

previous()をコールする前に、hasPrevious()をコールしてビュー・オブジェクトが最初の行にないことを確認してください。

次の例では、previous()を使用してビュー・オブジェクトmgrVOが1行ずつ逆方向に処理されます。


// Step backwards through the query ManagersRow backwardsRow = (ManagersRow) mgrVO.last(); System.out.println("Got last row:"+rowValues(backwardsRow,mgrVO)); while (mgrVO.hasPrevious()) { //make sure we can step backward backwardsRow = (ManagersRow) mgrVO.previous(); //step backward System.out.println("Got previous row:"+rowValues(backwardsRow,mgrVO)); }

関連項目

問合せの行を移動する方法
問合せの最初の行の検索
問合せの最後の行の検索
問合せの1行ずつの処理
主キーによる問合せでの行の検索