Package oracle.toplink.essentials.sessions

Examples of oracle.toplink.essentials.sessions.DatabaseRecord


     * INTERNAL:
     * Return DatabaseRow containing output fields and values.
     * Called only if shouldBuildOutputRow method returns true.
     */
    public AbstractRecord buildOutputRow(CallableStatement statement) throws SQLException {
        AbstractRecord row = new DatabaseRecord();
        for (int index = 0; index < parameters.size(); index++) {
            Object parameter = parameters.elementAt(index);
            if (parameter instanceof OutputParameterForCallableStatement) {
                OutputParameterForCallableStatement outParameter = (OutputParameterForCallableStatement)parameter;
                if (!outParameter.isCursor()) {
                    Object value = statement.getObject(index + 1);
                    DatabaseField field = outParameter.getOutputField();
                    row.put(field, value);
                }
            }
        }

        return row;
View Full Code Here


     * INTERNAL:
     * Add a field - value pair for LOB field into the context.
     */
    public void addContext(DatabaseField field, Object value) {
        if (contexts == null) {
            contexts = new DatabaseRecord(2);
        }
        contexts.add(field, value);
    }
View Full Code Here

                values.add(null);
            }
        }

        // Row creation is optimized through sharing the same fields for the entire result set.
        return new DatabaseRecord(fields, values);
    }
View Full Code Here

    /**
     * ADVANCED:
     * Set all of the objects from the given Expression to be invalid in the TopLink Identity Maps
     */
    public void invalidateObjects(Expression selectionCriteria) {
        invalidateObjects(getAllFromIdentityMap(selectionCriteria, selectionCriteria.getBuilder().getQueryClass(), new DatabaseRecord(1)));
    }
View Full Code Here

        if (argumentNames.size() != argumentValues.size()) {
            throw QueryException.argumentSizeMismatchInQueryAndQueryDefinition(this);
        }

        AbstractRecord row = new DatabaseRecord();
        for (int index = 0; index < argumentNames.size(); index++) {
            String argumentName = (String)argumentNames.elementAt(index);
            Object argumentValue = argumentValues.elementAt(index);
            row.put(new DatabaseField(argumentName), argumentValue);
        }

        return row;
    }
View Full Code Here

        List results = new ArrayList(databaseRecords.size() );
        SQLResultSetMapping mapping = this.getSQLResultSetMapping();
        for (Iterator iterator = databaseRecords.iterator(); iterator.hasNext();){
            if (mapping.getResults().size()>1){
                Object[] resultElement = new Object[mapping.getResults().size()];
                DatabaseRecord record = (DatabaseRecord)iterator.next();
                for (int i = 0;i<mapping.getResults().size();i++){
                    resultElement[i] = ((SQLResult)mapping.getResults().get(i)).getValueFromRecord(record, this);
                }
                results.add(resultElement);
            }else if (mapping.getResults().size()==1) {
                DatabaseRecord record = (DatabaseRecord)iterator.next();
                results.add( ((SQLResult)mapping.getResults().get(0)).getValueFromRecord(record, this));
            }else {
                return results;
            }
        }
View Full Code Here

    public Object getValueFromRecord(DatabaseRecord record, ResultSetMappingQuery query){
        //from the row data build result entity.
        // To do this let's collect the column based data for this entity from
        // the results and call build object with this new row.
        ClassDescriptor descriptor = query.getSession().getDescriptor(this.entityClass);
        DatabaseRecord entityRecord = new DatabaseRecord(descriptor.getFields().size());
        if (descriptor.hasInheritance()){
            if (this.discriminatorColumn != null){
                Object value = record.get(this.discriminatorColumn);
                if (value == null){
                    throw QueryException.discriminatorColumnNotSelected(this.discriminatorColumn, query.getSQLResultSetMapping().getName());
                }
                entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), record.get(this.discriminatorColumn));
            }else{
                entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), record.get(descriptor.getInheritancePolicy().getClassIndicatorField()));
            }
            // if the descriptor uses inheritance and multiple types may have been read
            //get the correct descriptor.
            if (descriptor.hasInheritance() && descriptor.getInheritancePolicy().shouldReadSubclasses()) {
                Class classValue = descriptor.getInheritancePolicy().classFromRow(entityRecord, query.getSession());
                descriptor = query.getSession().getDescriptor(classValue);
            }
        }
        for (Iterator mappings = descriptor.getMappings().iterator(); mappings.hasNext();){
            DatabaseMapping mapping = (DatabaseMapping)mappings.next();
            FieldResult fieldResult = (FieldResult)this.getFieldResults().get(mapping.getAttributeName());
            if (fieldResult != null){
                if (mapping.getFields().size() == 1 ){
                    entityRecord.put(mapping.getFields().firstElement(), record.get(fieldResult.getColumnName()));
                }else if (mapping.getFields().size() >1){
                    getValueFromRecordForMapping(entityRecord,mapping,fieldResult,record);
                }
            }else{
                for (Iterator fields = mapping.getFields().iterator(); fields.hasNext();){
                    DatabaseField field = (DatabaseField)fields.next();
                    entityRecord.put(field, record.get(field));
                }
            }
        }
        query.setReferenceClass(this.entityClass);
        query.setDescriptor(descriptor);
View Full Code Here

                if (item.getDescriptor().getAllFields().size() + item.getResultIndex() > row.size()) {
                    throw QueryException.reportQueryResultSizeMismatch(item.getDescriptor().getAllFields().size() + item.getResultIndex(), row.size());
                }
                Vector trimedFields = Helper.copyVector(row.getFields(), item.getResultIndex(), row.size());
                Vector trimedValues = Helper.copyVector(row.getValues(), item.getResultIndex(), row.size());
                AbstractRecord subRow = new DatabaseRecord(trimedFields, trimedValues);
                value = item.getDescriptor().getObjectBuilder().buildObject(query, subRow, joinManager);
                // GF_ISSUE_395
                if (this.key != null){
                    List list = item.getDescriptor().getObjectBuilder().extractPrimaryKeyFromRow(subRow, query.getSession());
                    if(list!=null){//GF bug3233, Distinct Processing fails with NPE when referenced target is null in database.
View Full Code Here

            // need error checking and appropriate exception for non-existing query
            databaseQuery = getActiveSession().getQuery(queryName);
            if (databaseQuery != null) {
                if (!databaseQuery.isPrepared()){
                    //prepare the query before cloning, this ensures we do not have to continually prepare on each usage
                    databaseQuery.prepareCall(getActiveSession(), new DatabaseRecord());
                }
                //Bug5040609  Make a clone of the original DatabaseQuery for this EJBQuery
                databaseQuery = (DatabaseQuery)databaseQuery.clone();
            } else {
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unable_to_find_named_query", new Object[] {queryName}));
View Full Code Here

TOP

Related Classes of oracle.toplink.essentials.sessions.DatabaseRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.