Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.InvalidStateException


        OpCallbacks call) {
        // check for illegal nulls
        if (objval == null) {
            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 (!_broker.isDetachedNew() && _broker.isDetached(obj))
                return; // allow but ignore

            sm = _broker.getStateManager(obj);
            if (sm == null || !sm.isPersistent())
                throw new InvalidStateException(_loc.get("cant-cascade-persist",
                    Exceptions.toString(obj), vmd,
                    Exceptions.toString(_sm.getManagedInstance()))).
                    setFailedObject(obj);
        } else {
            sm = _broker.getStateManager(obj);
View Full Code Here

        if (mdf instanceof DelegatingMetaDataFactory)
            mdf = ((DelegatingMetaDataFactory) mdf).getInnermostDelegate();
        if (mdf instanceof ObjectIdLoader)
            ((ObjectIdLoader) mdf).setLoadObjectIds();
        else if (fatal)
            throw new InvalidStateException(_loc.get("factory-not-oidloader")).
                setFatal(true);
    }
View Full Code Here

    protected Object nextInternal(JDBCStore store, ClassMapping mapping)
        throws Exception {
        // if needed, grab the next handful of ids
        Status stat = getStatus(mapping);
        if (stat == null)
            throw new InvalidStateException(_loc.get("bad-seq-type",
                getClass(), mapping));

        while (true) {
            synchronized (stat) {
                // make sure seq is at least 1, since autoassigned ids of 0 can
View Full Code Here

        if (_log.isTraceEnabled())
            _log.trace(_loc.get("insert-seq"));

        Object pk = getPrimaryKey(mapping);
        if (pk == null)
            throw new InvalidStateException(_loc.get("bad-seq-type",
                getClass(), mapping));

        DBDictionary dict = _conf.getDBDictionaryInstance();
        SQLBuffer insert = new SQLBuffer(dict).append("INSERT INTO ").
            append(_pkColumn.getTable()).append(" (").
View Full Code Here

        if (_log.isTraceEnabled())
            _log.trace(_loc.get("update-seq"));

        Object pk = getPrimaryKey(mapping);
        if (pk == null)
            throw new InvalidStateException(_loc.get("bad-seq-type",
                getClass(), mapping));

        DBDictionary dict = _conf.getDBDictionaryInstance();
        SQLBuffer where = new SQLBuffer(dict).append(_pkColumn).append(" = ").
            appendValue(pk, _pkColumn);
View Full Code Here

        Object prev = getSet(col);
        if (prev != null) {
            if (prev == NULL)
                prev = null;
            if (!rowValueEquals(prev, val)) {
                throw new InvalidStateException(_loc.get("diff-values",
                    new Object[]{ col.getFullName(),
                        (prev == null) ? null : prev.getClass(), prev,
                        (val == null) ? null : val.getClass(), val })).
                    setFatal(true);
            }
View Full Code Here

    }

    private SchemaGroup assertSchemaGroup() {
        SchemaGroup local = getSchemaGroup();
        if (local == null)
            throw new InvalidStateException(_loc.get("tool-norepos"));
        return local;
    }
View Full Code Here

     * content of the exception varies whether TRACE is enabled or not.
     */
    private 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

        excs = new ArrayList(_transactional.size());
        for (Iterator trans = _transactional.values().iterator();
            trans.hasNext();) {
            Collection brokers = (Collection) trans.next();
            for (Iterator itr = brokers.iterator(); itr.hasNext();) {
                excs.add(new InvalidStateException(_loc.get("active")).
                    setFailedObject(itr.next()));
            }
        }

        if (!excs.isEmpty())
            throw new InvalidStateException(_loc.get("nested-exceps")).
                setNestedThrowables((Throwable[]) excs.toArray
                    (new Throwable[excs.size()]));
    }
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.