Search in sources :

Example 6 with ModelException

use of com.sun.jdo.api.persistence.model.ModelException in project Payara by payara.

the class MappingTableElementImpl method removeKeyColumn.

/**
 * Removes a column from the primary key of columns in this mapping table.
 * This method should only be used to manipulate the key columns of the
 * primary table.  The secondary table key columns should be manipulated
 * using MappingReferenceKeyElement methods for pairs.
 * @param columnName the relative name of the column to be removed
 * @exception ModelException if impossible
 */
public void removeKeyColumn(String columnName) throws ModelException {
    if (columnName != null) {
        try {
            fireVetoableChange(PROP_KEY_COLUMNS, null, null);
            if (!getKey().remove(columnName)) {
                throw new ModelException(I18NHelper.getMessage(getMessages(), // NOI18N
                "mapping.element.element_not_removed", columnName));
            }
            firePropertyChange(PROP_KEY_COLUMNS, null, null);
            // sync up runtime's object list too
            // @olsen: rather clear objects instead of maintaining them
            // getKeyObjects().remove(column);
            _keyObjects = null;
        } catch (PropertyVetoException e) {
            throw new ModelVetoException(e);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ModelException(com.sun.jdo.api.persistence.model.ModelException) ModelVetoException(com.sun.jdo.api.persistence.model.ModelVetoException)

Aggregations

ModelException (com.sun.jdo.api.persistence.model.ModelException)6 ModelVetoException (com.sun.jdo.api.persistence.model.ModelVetoException)4 PropertyVetoException (java.beans.PropertyVetoException)4 MessageFormat (java.text.MessageFormat)2 RelationshipElement (com.sun.jdo.api.persistence.model.jdo.RelationshipElement)1 ArrayList (java.util.ArrayList)1