Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.InvalidStateException


    /**
     * Flush safely, catching reentrant calls.
     */
    private void flushSafe(int reason) {
        if ((_flags & FLAG_FLUSHING) != 0)
            throw new InvalidStateException(_loc.get("reentrant-flush"));

        _flags |= FLAG_FLUSHING;
        try {
            flush(reason);
        } finally {
View Full Code Here


        try {
            boolean removed = false;
            if (_derefAdditions != null)
                removed = _derefAdditions.remove(sm);
            if (!removed && (_derefCache == null || !_derefCache.remove(sm)))
                throw new InvalidStateException(_loc.get("not-derefed",
                    Exceptions.toString(sm.getManagedInstance()))).
                    setFailedObject(sm.getManagedInstance()).
                    setFatal(true);
        } finally {
            unlock();
View Full Code Here

    public void close() {
        beginOperation(false);
        try {
            // throw an exception if closing in an active local trans
            if (!_managed && (_flags & FLAG_ACTIVE) != 0)
                throw new InvalidStateException(_loc.get("active"));

            // only close if not active; if active managed trans wait
            // for completion
            _flags |= FLAG_CLOSE_INVOKED;
View Full Code Here

     * 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-notrace"))
                        .setFatal(true);
            else
                throw new InvalidStateException(_loc.get("closed"),
                        _closedException).setFatal(true);
        }
    }
View Full Code Here

     * Throw exception if a transaction-related operation is attempted and
     * no transaction is active.
     */
    private void assertTransactionOperation() {
        if ((_flags & FLAG_ACTIVE) == 0)
            throw new InvalidStateException(_loc.get("not-active"));
    }
View Full Code Here

            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

     * 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

                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

        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

                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

TOP

Related Classes of org.apache.openjpa.util.InvalidStateException

Copyright © 2018 www.massapicom. 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.