Search in sources :

Example 1 with TableDesc

use of com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc in project Payara by payara.

the class QueryPlan method addQueryTable.

/**
 * Identifies a database table which will become part of this
 * query plan.  We will build a QueryTable object describing its
 * use and return it.
 *
 * Note:  No join is constructed at this point for the table added.
 *
 * @param tableElement Identifies which table is being added.
 * @param persistenceConfig
 * 	If we are adding a foreign table the persistenceConfig parameter
 * 	holds the PersistenceConfig for the foreign Persistence Class.
 */
public QueryTable addQueryTable(TableElement tableElement, ClassDesc persistenceConfig) {
    ClassDesc _config = (persistenceConfig == null) ? this.config : persistenceConfig;
    TableDesc tableDesc = _config.findTableDesc(tableElement);
    if (tableDesc == null) {
        if (tableElement != null) {
            throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
            "core.configuration.classnotmappedtotable", _config.getPersistenceCapableClass().getName(), tableElement.getName().getName()));
        } else {
            throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
            "core.configuration.classnotmapped", _config.getPersistenceCapableClass().getName()));
        }
    }
    return addQueryTable(tableDesc);
}
Also used : JDOFatalInternalException(com.sun.jdo.api.persistence.support.JDOFatalInternalException) TableDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc) ClassDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.ClassDesc)

Example 2 with TableDesc

use of com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc in project Payara by payara.

the class SelectStatement method generateForUpdateClause.

private StringBuffer generateForUpdateClause(boolean updateLockRequired) {
    StringBuffer forUpdateClause = new StringBuffer();
    if (updateLockRequired) {
        // Check if vendor actually supports updatelock
        if (!vendorType.isUpdateLockSupported()) {
            // But vendor is not supporting it. Do not allow user to proceed
            throw new JDOFatalDataStoreException(I18NHelper.getMessage(messages, // NOI18N
            "sqlstore.selectstatement.noupdatelocksupport"));
        }
        // generating the ForUpdate Clause
        String vendorForUpdate = vendorType.getForUpdate().trim();
        boolean vendorHasForUpdateClause = (vendorForUpdate.length() != 0);
        if (vendorHasForUpdateClause) {
            forUpdateClause.append(" ").append(vendorForUpdate).append(" ");
            if (vendorType.isLockColumnListSupported()) {
                for (int i = 0; i < tableList.size(); i++) {
                    QueryTable queryTable = (QueryTable) tableList.get(i);
                    if (isUpdateLockRequired(queryTable)) {
                        TableDesc tableDesc = queryTable.getTableDesc();
                        // Get the first column of primary key
                        ColumnElement ce = (ColumnElement) tableDesc.getKey().getColumns().get(0);
                        // NOI18N
                        forUpdateClause.append("t").append(i).append(".");
                        appendQuotedText(forUpdateClause, ce.getName().getName());
                        // NOI18N
                        forUpdateClause.append(", ");
                    }
                }
                // Remove trailing ", "
                forUpdateClause.delete(forUpdateClause.length() - 2, forUpdateClause.length());
            }
        }
    }
    return forUpdateClause;
}
Also used : TableDesc(com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc) ColumnElement(org.netbeans.modules.dbschema.ColumnElement) JDOFatalDataStoreException(com.sun.jdo.api.persistence.support.JDOFatalDataStoreException)

Aggregations

TableDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc)2 JDOFatalDataStoreException (com.sun.jdo.api.persistence.support.JDOFatalDataStoreException)1 JDOFatalInternalException (com.sun.jdo.api.persistence.support.JDOFatalInternalException)1 ClassDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.ClassDesc)1 ColumnElement (org.netbeans.modules.dbschema.ColumnElement)1