@SuppressWarnings("unchecked") public <T extends PO>T firstOnly() throws DBException {
  T po=null;
  String sql=buildSQL(null,true);
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  try {
    pstmt=DB.prepareStatement(sql,trxName);
    rs=createResultSet(pstmt);
    if (rs.next()) {
      po=(T)table.getPO(rs,trxName);
    }
    if (rs.next()) {
      throw new DBException("QueryMoreThanOneRecordsFound");
    }
  }
 catch (  SQLException e) {
    log.log(Level.SEVERE,sql,e);
    throw new DBException(e,sql);
  }
 finally {
    DB.close(rs,pstmt);
    rs=null;
    pstmt=null;
  }
  return po;
}

@ SuppressWarnings ( "unchecked" ) public < T extends PO > T firstOnly ( ) throws DBException { T po = null ; String sql = buildSQL ( null , true ) ; PreparedStatement pstmt = null ; ResultSet rs = null ; try { pstmt = DB . prepareStatement ( sql , trxName ) ; rs = createResultSet ( pstmt ) ; if ( rs . next ( ) ) { po = ( T ) table . getPO ( rs , trxName ) ; } if ( rs . next ( ) ) { throw new DBException ( "QueryMoreThanOneRecordsFound" ) ; } } catch ( SQLException e ) { log . log ( Level . SEVERE , sql , e ) ; throw new DBException ( e , sql ) ; } finally { DB . close ( rs , pstmt ) ; rs = null ; pstmt = null ; } return po ; }
return first po that match query criteria . if there are more records that match criteria an exception will be throwed
