/** * Perform the query on the database, and prepare the array of returned DO objects. * * @exception DataObjectException If a database access error occurs. * @exception NonUniqueQueryException If too many rows were found. */ private void runQuery() throws DataObjectException, NonUniqueQueryException { needToRun = false; arrayIndex = -1; DBQuery dbQuery = null; try { Vector results; /* if ( cacheHits.size() > 0 ) { // The setQuery methods build up the cacheHits. // If the cache had our desired objects, // we don't query the database, so we have no ResultSet. results = cacheHits; // executeQuery saw cache hits } else { // If the cache doesn't exist, or could not handle the query, // then we actually query the database. dbQuery = Enhydra.getDatabaseManager().createQuery(); dbQuery.query( this ); // invokes executeQuery results = new Vector(); while ( resultSet.next() ) { results.addElement( new SoftwareCandidateDO ( resultSet ) ); } } */ if (/* partialCache && */ 0 == cacheHits.size()) hitDb = true; if (hitDb) { dbQuery = Enhydra.getDatabaseManager().createQuery(); dbQuery.query(this); // invokes executeQuery results = new Vector(); while (resultSet.next()) { // results.addElement( new SoftwareCandidateDO ( resultSet ) ); results.addElement(SoftwareCandidateDO.createExisting(resultSet)); } } else { results = cacheHits; // executeQuery saw cache hits } if (results.size() > 1 && uniqueInstance) throw new NonUniqueQueryException("Too many rows returned from database"); DOs = new SoftwareCandidateDO[results.size()]; for (int i = 0; i < results.size(); i++) { DOs[i] = (SoftwareCandidateDO) results.elementAt(i); } arrayIndex = 0; } catch (SQLException se) { if (null == se.getSQLState()) { throw new DataObjectException("Unknown SQLException", se); } if (se.getSQLState().startsWith("02") && se.getErrorCode() == 100) { throw new DataObjectException("Update or delete DO is out of synch", se); } else if (se.getSQLState().equals("S1000") && se.getErrorCode() == -268) { throw new DataObjectException("Integrity constraint violation", se); } else { throw new DataObjectException("Data Object Error", se); } } catch (ObjectIdException oe) { throw new DataObjectException("Object ID Error", oe); } catch (DatabaseManagerException de) { throw new DataObjectException("Database connection Error", de); } finally { if (null != dbQuery) dbQuery.release(); } }