/** * Allow for the field order to be matched if required. * This is required for custom SQL. */ public void matchFieldOrder(ResultSet resultSet, DatabaseAccessor accessor, AbstractSession session) { if ((getFields() != null) && (!isFieldMatchingRequired())) { return; } setFields(accessor.buildSortedFields(getFields(), resultSet, session)); }
/** * Build the given result set into a list objects. Assumes there is an * execute call available and therefore should not be called unless an * execute statement was issued by the user. */ protected List buildResultRecords(ResultSet resultSet) { try { AbstractSession session = (AbstractSession) getActiveSession(); DatabaseAccessor accessor = (DatabaseAccessor) executeCall.getQuery().getAccessor(); executeCall.setFields(null); executeCall.matchFieldOrder(resultSet, accessor, session); ResultSetMetaData metaData = resultSet.getMetaData(); List result = new Vector(); while (resultSet.next()) { result.add(accessor.fetchRow(executeCall.getFields(), executeCall.getFieldsArray(), resultSet, metaData, session)); } // The result set must be closed in case the statement is cached and not closed. resultSet.close(); return result; } catch (Exception e) { setRollbackOnly(); throw new PersistenceException(e); } }
/** * Allow for the field order to be matched if required. * This is required for custom SQL. */ public void matchFieldOrder(ResultSet resultSet, DatabaseAccessor accessor, AbstractSession session) { if ((getFields() != null) && (!isFieldMatchingRequired())) { return; } setFields(accessor.buildSortedFields(getFields(), resultSet, session)); }
/** * Allow for the field order to be matched if required. * This is required for custom SQL. */ public void matchFieldOrder(ResultSet resultSet, DatabaseAccessor accessor, AbstractSession session) { if ((getFields() != null) && (!isFieldMatchingRequired())) { return; } setFields(accessor.buildSortedFields(getFields(), resultSet, session)); }
ObjectBuilder builder = this.descriptor.getObjectBuilder(); while (resultSet.next()) { results.add(builder.buildObjectFromResultSet(this, this.joinedAttributeManager, resultSet, session, accessor, metaData, platform, call.getFields(), call.getFieldsArray()));
protected Object processResultSet(ResultSet resultSet, DatabaseCall dbCall, PreparedStatement statement, DatabaseAccessor accessor, AbstractSession session) throws SQLException { Object result = null; ResultSetMetaData metaData = resultSet.getMetaData(); session.startOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL); try { if (dbCall.isOneRowReturned()) { if (resultSet.next()) { result = accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session); if (resultSet.next()) { // Raise more rows event, some apps may interpret as error or warning. if (session.hasEventManager()) { session.getEventManager().moreRowsDetected(dbCall); } } } else { result = null; } } else { Vector results = new Vector(20); while (resultSet.next()) { results.addElement(accessor.fetchRow(dbCall.getFields(), resultSet, metaData, session)); } result = results; } resultSet.close();// This must be closed incase the statement is cached and not closed. } finally { session.endOperationProfile(SessionProfiler.ROW_FETCH, dbCall.getQuery(), SessionProfiler.ALL); } return result; }
return this.descriptor.getObjectBuilder().buildObjectFromResultSet(this, null, resultSet, session, accessor, metaData, platform, call.getFields(), call.getFieldsArray()); } catch (SQLException exception) { exceptionOccured = true;
/** * INTERNAL: */ public Cursor(DatabaseCall call, CursorPolicy policy) { ReadQuery query = policy.getQuery(); this.query = query; this.session = query.getSession(); this.executionSession = session.getExecutionSession(query); this.statement = call.getStatement(); this.fields = call.getFields(); this.resultSet = call.getResult(); this.policy = policy; this.objectCollection = new Vector(); if (query.getSession().isUnitOfWork() && query.isObjectLevelReadQuery()) { // Call register on the cursor itself. This will set up // incremental conforming by setting the // selection criteria clone and arguments, and building the // intially conforming index (scans the UOW cache). // The incremental registration/conforming is done // in retrieveNext/PreviousObject -> buildAndRegisterObject ((ObjectLevelReadQuery)query).registerResultInUnitOfWork(this, (UnitOfWorkImpl)this.session, query.getTranslationRow(), false);// object collection is empty, so setting irrelevant. } }
ObjectBuilder builder = this.descriptor.getObjectBuilder(); while (resultSet.next()) { results.add(builder.buildObjectFromResultSet(this, this.joinedAttributeManager, resultSet, session, accessor, metaData, platform, call.getFields(), call.getFieldsArray()));
/** * INTERNAL: */ public Cursor(DatabaseCall call, CursorPolicy policy) { ReadQuery query = policy.getQuery(); this.query = query; this.session = query.getSession(); this.executionSession = session.getExecutionSession(query); this.statement = call.getStatement(); this.fields = call.getFields(); this.resultSet = call.getResult(); this.policy = policy; this.objectCollection = new Vector(); if (query.getSession().isUnitOfWork() && query.isObjectLevelReadQuery()) { // Call register on the cursor itself. This will set up // incremental conforming by setting the // selection criteria clone and arguments, and building the // intially conforming index (scans the UOW cache). // The incremental registration/conforming is done // in retrieveNext/PreviousObject -> buildAndRegisterObject ((ObjectLevelReadQuery)query).registerResultInUnitOfWork(this, (UnitOfWorkImpl)this.session, query.getTranslationRow(), false);// object collection is empty, so setting irrelevant. } }
return this.descriptor.getObjectBuilder().buildObjectFromResultSet(this, null, resultSet, session, accessor, metaData, platform, call.getFields(), call.getFieldsArray()); } catch (SQLException exception) { exceptionOccured = true;
/** * INTERNAL: */ public Cursor(DatabaseCall call, CursorPolicy policy) { this.session = policy.getQuery().getSession(); this.executionSession = session.getExecutionSession(policy.getQuery()); this.statement = call.getStatement(); this.fields = call.getFields(); this.resultSet = call.getResult(); this.policy = policy; setObjectCollection(new Vector()); if (getQuery().getSession().isUnitOfWork() && getQuery().isObjectLevelReadQuery()) { // Call register on the cursor itself. This will set up // incremental conforming by setting the // selection criteria clone and arguments, and building the // intially conforming index (scans the UOW cache). // The incremental registration/conforming is done // in retrieveNext/PreviousObject -> buildAndRegisterObject ObjectLevelReadQuery query = (ObjectLevelReadQuery)getQuery(); query.registerResultInUnitOfWork(this, (UnitOfWorkImpl)this.session, getQuery().getTranslationRow(), false);// object collection is empty, so setting irrelevant. } }
results.add(fetchRow(dbCall.getFields(), dbCall.getFieldsArray(), resultSet, metaData, session)); hasNext = resultSet.next();
results.addElement(fetchRow(dbCall.getFields(), resultSet, metaData, session)); hasNext = resultSet.next();
results.add(fetchRow(dbCall.getFields(), dbCall.getFieldsArray(), resultSet, metaData, session)); hasNext = resultSet.next();