Search in sources :

Example 26 with JDOFatalInternalException

use of com.sun.jdo.api.persistence.support.JDOFatalInternalException in project Payara by payara.

the class UpdateQueryPlan method addColumn.

/**
 * Specifies an field the data for which needs to be updated,
 * and the mapped columns for which therefor need to be updated.
 * For update queries the column will be put in the set lists,
 * and for insert queries the column will be put into the
 * insert values lists.
 *
 * @param fieldDesc Updated field corresponding to a column in the database.
 * @param value New value.
 */
private void addColumn(LocalFieldDesc fieldDesc, Object value) {
    // Ignore secondary tracked fields.
    if ((fieldDesc.sqlProperties & FieldDesc.PROP_SECONDARY_TRACKED_FIELD) > 0) {
        return;
    }
    for (Iterator iter = fieldDesc.getColumnElements(); iter.hasNext(); ) {
        ColumnElement columnElement = (ColumnElement) iter.next();
        TableElement tableElement = columnElement.getDeclaringTable();
        if (tableElement == null) {
            throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
            "core.configuration.fieldnotable", fieldDesc.getName()));
        }
        QueryTable t = findQueryTable(tableElement);
        UpdateStatement s = null;
        if (t == null) {
            t = addQueryTable(tableElement, null);
            s = (UpdateStatement) addStatement(t);
        } else {
            s = (UpdateStatement) getStatement(t);
        }
        if (fieldDesc.isVersion() && action == ACT_UPDATE) {
            // For update, version columns will be flagged specially.
            s.addVersionColumn(columnElement);
        } else {
            s.addColumn(columnElement, value);
        }
    }
}
Also used : JDOFatalInternalException(com.sun.jdo.api.persistence.support.JDOFatalInternalException) Iterator(java.util.Iterator) ColumnElement(org.netbeans.modules.dbschema.ColumnElement) TableElement(org.netbeans.modules.dbschema.TableElement)

Aggregations

JDOFatalInternalException (com.sun.jdo.api.persistence.support.JDOFatalInternalException)26 com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint (com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint)4 ColumnElement (org.netbeans.modules.dbschema.ColumnElement)4 LocalFieldDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.LocalFieldDesc)3 ArrayList (java.util.ArrayList)3 JDODataStoreException (com.sun.jdo.api.persistence.support.JDODataStoreException)2 JDOException (com.sun.jdo.api.persistence.support.JDOException)2 JDOUnsupportedOptionException (com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException)2 JDOUserException (com.sun.jdo.api.persistence.support.JDOUserException)2 RetrieveDescImpl (com.sun.jdo.spi.persistence.support.sqlstore.sql.RetrieveDescImpl)2 Field (java.lang.reflect.Field)2 SQLException (java.sql.SQLException)2 Iterator (java.util.Iterator)2 TableElement (org.netbeans.modules.dbschema.TableElement)2 JDOQueryException (com.sun.jdo.api.persistence.support.JDOQueryException)1 ClassDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.ClassDesc)1 FieldDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.FieldDesc)1 ForeignFieldDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.ForeignFieldDesc)1 TableDesc (com.sun.jdo.spi.persistence.support.sqlstore.model.TableDesc)1 DateType (com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.DateType)1