Search in sources :

Example 1 with Concurrency

use of com.sun.jdo.spi.persistence.support.sqlstore.sql.concurrency.Concurrency in project Payara by payara.

the class SQLStoreManager method retrieve.

/**
 * The retrieve method builds and executes the SQL query described by
 * the action parameter.
 *
 * @param action
 *     The action parameter holds the RetrieveDesc describing what
 *     should be selected from the database.
 *
 * @param parameters
 *     Query parameters.
 */
public Object retrieve(PersistenceManager pm, RetrieveDesc action, ValueFetcher parameters) {
    if (action == null) {
        throw new JDOFatalInternalException(I18NHelper.getMessage(messages, "core.generic.nullparam", // NOI18N
        "action"));
    }
    if (!(action instanceof RetrieveDescImpl)) {
        throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
        "core.generic.notinstanceof", action.getClass().getName(), // NOI18N
        "RetrieveDescImpl"));
    }
    RetrieveDescImpl retrieveAction = ((RetrieveDescImpl) action);
    ClassDesc config = retrieveAction.getConfig();
    Concurrency concurrency = config.getConcurrency(pm.isOptimisticTransaction());
    SelectQueryPlan plan = retrieveAction.buildQueryPlan(this, concurrency);
    ArrayList statements = plan.getStatements();
    Object result = null;
    SelectStatement s = (SelectStatement) statements.get(0);
    result = executeQuery(pm, s, concurrency, parameters);
    if ((plan.options & RetrieveDescImpl.OPT_AGGREGATE) == 0) {
        if ((plan.options & RetrieveDescImpl.OPT_DISTINCT) > 0) {
            if (((plan.options & RetrieveDescImpl.OPT_FOR_UPDATE) > 0 && !vendorType.isDistinctSupportedWithUpdateLock())) {
                HashSet hash = new HashSet();
                for (Iterator iter = ((Collection) result).iterator(); iter.hasNext(); ) {
                    Object temp = iter.next();
                    if (!hash.contains(temp)) {
                        hash.add(temp);
                    } else {
                        iter.remove();
                    }
                }
            }
        }
    }
    return result;
}
Also used : RetrieveDescImpl(com.sun.jdo.spi.persistence.support.sqlstore.sql.RetrieveDescImpl) Concurrency(com.sun.jdo.spi.persistence.support.sqlstore.sql.concurrency.Concurrency)

Aggregations

RetrieveDescImpl (com.sun.jdo.spi.persistence.support.sqlstore.sql.RetrieveDescImpl)1 Concurrency (com.sun.jdo.spi.persistence.support.sqlstore.sql.concurrency.Concurrency)1