Examples of InvalidStateException


Examples of org.apache.openjpa.util.InvalidStateException

            throw new InvalidStateException(_loc.get("not-active"));
    }

    public void assertNontransactionalRead() {
        if ((_flags & FLAG_ACTIVE) == 0 && !_nontransRead)
            throw new InvalidStateException(_loc.get("non-trans-read"));
    }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

     * updateClause and isolationLevel hints
     */
    protected String getForUpdateClause(JDBCFetchConfiguration fetch,
        boolean isForUpdate, Select sel) {
        if (fetch != null && fetch.getIsolation() != -1) {
            throw new InvalidStateException(_loc.get(
                "isolation-level-config-not-supported", getClass().getName()));
        } else if (isForUpdate && !simulateLocking) {
            assertSupport(supportsSelectForUpdate, "SupportsSelectForUpdate");
            return forUpdateClause;
        } else {
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

                prev = null;
            if (!rowValueEquals(prev, val)) {
              if (isDefaultValue(prev) || allowsUpdate(col, prev, val)) {
                super.setObject(col, val, metaType, overrideDefault);
              } else if (!isDefaultValue(prev)) {
                throw new InvalidStateException(_loc.get("diff-values",
                    new Object[]{ col.getFullDBIdentifier().getName(),
                            (prev == null) ? null : prev.getClass(), prev,
                            (val == null) ? null : val.getClass(), val })).
                    setFatal(true);
              } else {
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

        if (objval == null) {
            // If we have an AUTOASSIGN strategy that means that we have a field that is GenerationType.IDENTITY so
            // skip checking to see if the value is null as it will get assigned later in flush processing.
            if (fmd.getValueStrategy() != ValueStrategies.AUTOASSIGN) {
                if (fmd.getNullValue() == FieldMetaData.NULL_EXCEPTION || fmd.getDeclaredTypeCode() == JavaTypes.OID)
                    throw new InvalidStateException(_loc.get("null-value", fmd.getName(), _sm.getManagedInstance()))
                        .setFatal(true);
            }
            return false;
        }

        // nothing else to do for non-persistent
        if (fmd.getManagement() != FieldMetaData.MANAGE_PERSISTENT)
            return false;

        // don't allow managed objectid field value
        if (fmd.getDeclaredTypeCode() == JavaTypes.OID) {
            _sm.assertNotManagedObjectId(objval);
            if (_sm.getObjectId() != null
                && !objval.equals(((ObjectId) _sm.getObjectId()).getId()))
                throw new InvalidStateException(_loc.get("changed-oid",
                    _sm.getObjectId(), objval,
                    Exceptions.toString(_sm.getManagedInstance()))).
                    setFatal(true);
        }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

                if (((StoreContext)_broker).getAllowReferenceToSiblingContext()
                 && ImplHelper.isManageable(obj)
                 && ((PersistenceCapable)obj).pcGetStateManager() != null) {
                    return;
                } else {
                    throw new InvalidStateException(_loc.get("cant-cascade-persist",
                            vmd.toString(), Exceptions.toString(obj),
                            sm == null ? " unmanaged" : sm.getPCState().getClass().getSimpleName()))
                    .setFailedObject(obj);
                }
            }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

     * content of the exception varies whether TRACE is enabled or not.
     */
    public void assertOpen() {
        if (_closed) {
            if (_closedException == null// TRACE not enabled
                throw new InvalidStateException(_loc
                        .get("closed-factory-notrace"));
            else
                throw new InvalidStateException(_loc.get("closed-factory"))
                        .setCause(_closedException);
        }
    }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

            return;

        excs = new ArrayList<Throwable>(_transactional.size());
        for (Collection<Broker> brokers : _transactional.values()) {
            for (Broker broker : brokers) {
                excs.add(new InvalidStateException(_loc.get("active")).setFailedObject(broker));
            }
        }

        if (!excs.isEmpty())
            throw new InvalidStateException(_loc.get("nested-exceps")).
                setNestedThrowables((Throwable[]) excs.toArray(new Throwable[excs.size()]));
    }
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

            return false;
       
        // Throw exception if field already has a value assigned.
        // @GeneratedValue overrides POJO initial values and setter methods
        if (!fmd.isValueGenerated() && !isDefaultValue(field))
            throw new InvalidStateException(_loc.get(
                "existing-value-override-excep", fmd.getFullName(false)));

        // for primary key fields, assign the object id and recache so that
        // to the user, so it looks like the oid always matches the pk fields
        if (fmd.isPrimaryKey() && !isEmbedded())
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

    public Object fetchInitialField(int field) {
        FieldMetaData fmd = _meta.getField(field);
        if (_broker.getRestoreState() == RestoreState.RESTORE_NONE
            && ((_flags & FLAG_INVERSES) == 0
            || fmd.getInverseMetaDatas().length == 0))
            throw new InvalidStateException(_loc.get("restore-unset"));

        switch (fmd.getDeclaredTypeCode()) {
            case JavaTypes.DATE:
            case JavaTypes.CALENDAR:
            case JavaTypes.ARRAY:
            case JavaTypes.COLLECTION:
            case JavaTypes.MAP:
            case JavaTypes.OBJECT:
                // if we're not saving mutable types, throw an exception
                if (_broker.getRestoreState() != RestoreState.RESTORE_ALL
                    && ((_flags & FLAG_INVERSES) == 0
                    || fmd.getInverseMetaDatas().length == 0))
                    throw new InvalidStateException(_loc.get
                        ("mutable-restore-unset"));
        }

        lock();
        try {
            if (_saved == null || !_loaded.get(field) || !isFieldDirty(field))
                return fetchField(field, false);

            // if the field is dirty but we never loaded it, we can't restore it
            if (_saved.getUnloaded().get(field))
                throw new InvalidStateException(_loc.get("initial-unloaded",
                    fmd));

            provideField(_saved.getState(), _single, field);
            return fetchField(_single, fmd);
        } finally {
View Full Code Here

Examples of org.apache.openjpa.util.InvalidStateException

            else
                setPCState(_state.beforeRead(this, field));
        } else if (_broker.getNontransactionalRead())
            setPCState(_state.beforeNontransactionalRead(this, field));
        else
            throw new InvalidStateException(_loc.get("non-trans-read")).
                setFailedObject(getManagedInstance());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.