/** * initFromResultSet initializes the data members from NewDBTable. This code was separated from * the ResultSet constructor so that createExisting(ResultSet) could handle VIEWs. */ private void initFromResultSet(ResultSet rs) throws SQLException, ObjectIdException, DataObjectException, DatabaseManagerException { // Constructing a DO from a ResultSet means we definitely need the // DataStruct ready for the setXxx methods invoked below. data = new TreeLeafDataStruct(); // writeMemberStuff uses the ResultSetExtraction.template // to build up the value for this tag: // the value is a series of calls to the DO set methods. setLeafNumber(rs.getInt("LeafNumber")); setProfile(jobmatch.data.ProfileDO.createExisting(rs.getBigDecimal("Profile", 0))); setMandatory(rs.getBoolean("Mandatory")); markClean(); }
/** * initFromResultSet initializes the data members from PersonalProfile. This code was separated * from the ResultSet constructor so that createExisting(ResultSet) could handle VIEWs. */ private void initFromResultSet(ResultSet rs) throws SQLException, ObjectIdException, DataObjectException, DatabaseManagerException { // Constructing a DO from a ResultSet means we definitely need the // DataStruct ready for the setXxx methods invoked below. data = new PersonalProfileDataStruct(); // writeMemberStuff uses the ResultSetExtraction.template // to build up the value for this tag: // the value is a series of calls to the DO set methods. setMinAge(rs.getInt("MinAge")); setMaxAge(rs.getInt("MaxAge")); setNationality(jobmatch.data.CountryDO.createExisting(rs.getBigDecimal("Nationality", 0))); setSex(rs.getString("Sex")); markClean(); }
/** * 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(); } }