FileDocCategorySizeDatePackage
DirectReadQuery.javaAPI DocGlassfish v2 API5188Tue May 22 16:54:50 BST 2007oracle.toplink.essentials.queryframework

DirectReadQuery

public class DirectReadQuery extends DataReadQuery

Purpose: Concrete class to perform a direct read.

Responsibilities: Used in conjunction with DirectCollectionMapping. This can be used to read a single column of data (i.e. one field). A container (implementing Collection) of the data values is returned.

author
Yvon Lavoie
since
TOPLink/Java 1.0

Fields Summary
protected Converter
valueConverter
Allows user defined conversion between the result value and the database value.
Constructors Summary
public DirectReadQuery()
PUBLIC: Initialize the state of the query.

        super();
    
public DirectReadQuery(String sqlString)
PUBLIC: Initialize the query to use the specified SQL string.

        super(sqlString);
    
public DirectReadQuery(Call call)
PUBLIC: Initialize the query to use the specified call.

        super(call);
    
Methods Summary
public java.lang.ObjectbuildObject(oracle.toplink.essentials.internal.sessions.AbstractRecord row)
INTERNAL: Used by cursored stream. Return the first field in the row.

        Object value = row.get(row.getFields().firstElement());
        if (getValueConverter() != null) {
            value = getValueConverter().convertDataValueToObjectValue(value, session);
        }
        return value;
    
public java.lang.ObjectexecuteNonCursor()
INTERNAL: The results are *not* in a cursor, build the collection.

        ContainerPolicy cp = getContainerPolicy();

        Vector rows = getQueryMechanism().executeSelect();
        Object result = cp.containerInstance(rows.size());
        DatabaseField resultDirectField = null;

        for (Enumeration stream = rows.elements(); stream.hasMoreElements();) {
            AbstractRecord row = (AbstractRecord)stream.nextElement();
            if (resultDirectField == null) {
                resultDirectField = (DatabaseField)row.getFields().firstElement();
            }
            Object value = row.get(resultDirectField);
            if (getValueConverter() != null) {
                value = getValueConverter().convertDataValueToObjectValue(value, session);
            }
            cp.addInto(value, result, getSession());
        }
        return result;
    
public oracle.toplink.essentials.mappings.converters.ConvertergetValueConverter()
PUBLIC: Return the converter on the query. A converter can be used to convert between the result value and database value.

        return valueConverter;
    
public voidsetValueConverter(oracle.toplink.essentials.mappings.converters.Converter valueConverter)
PUBLIC: Set the converter on the query. A converter can be used to convert between the result value and database value.

        this.valueConverter = valueConverter;