Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.UserException


        if (ImplHelper.isManageable(obj)) {
            PersistenceCapable pc = ImplHelper.toPersistenceCapable(obj, _conf);
            if (pc.pcGetGenericContext() == this)
                return (StateManagerImpl) pc.pcGetStateManager();
            if (assertThisContext && pc.pcGetGenericContext() != null)
                throw new UserException(_loc.get("not-managed",
                    Exceptions.toString(obj))).setFailedObject(obj);
        }
        return null;
    }
View Full Code Here


        // check for different instances of the PersistenceCapable interface
        // and throw a better error that mentions the class loaders
        Class[] intfs = obj.getClass().getInterfaces();
        for (int i = 0; intfs != null && i < intfs.length; i++) {
            if (intfs[i].getName().equals(PersistenceCapable.class.getName())) {
                throw new UserException(_loc.get("pc-loader-different",
                    Exceptions.toString(obj),
                    (ClassLoader) AccessController.doPrivileged(
                        J2DoPrivHelper.getClassLoaderAction(
                            PersistenceCapable.class)),
                    (ClassLoader) AccessController.doPrivileged(
                        J2DoPrivHelper.getClassLoaderAction(intfs[i]))))
                    .setFailedObject(obj);
            }
        }

        // not enhanced
        throw new UserException(_loc.get("pc-cast",
            Exceptions.toString(obj))).setFailedObject(obj);
    }
View Full Code Here

            // initializing persistent instance; put in main cache
            StateManagerImpl orig = (StateManagerImpl) _main.put
                (sm.getObjectId(), sm);
            if (orig != null) {
                _main.put(sm.getObjectId(), orig);
                throw new UserException(_loc.get("dup-load",
                    sm.getObjectId(), Exceptions.toString
                    (orig.getManagedInstance()))).
                    setFailedObject(sm.getManagedInstance());
            }
        }
View Full Code Here

            // instance with the same oid
            orig = (StateManagerImpl) _main.put(sm.getObjectId(), sm);
            if (orig != null) {
                _main.put(sm.getObjectId(), orig);
                if (!orig.isDeleted())
                    throw new UserException(_loc.get("dup-oid-assign",
                        sm.getObjectId(), Exceptions.toString
                        (sm.getManagedInstance()))).
                        setFailedObject(sm.getManagedInstance());

                // same oid as deleted instance; put in conflict cache
View Full Code Here

                    : (StateManagerImpl) _conflicts.remove(id);
                if (orig == sm) {
                    orig = (StateManagerImpl) _main.put(id, sm);
                    if (orig != null && !orig.isDeleted()) {
                        _main.put(sm.getObjectId(), orig);
                        throw new UserException(_loc.get("dup-oid-assign",
                            sm.getObjectId(), Exceptions.toString
                            (sm.getManagedInstance()))).setFailedObject
                            (sm.getManagedInstance()).setFatal(true);
                    }
                }
                return;
            }

            // oid changed, so it must previously have been a new instance
            // without an assigned oid.  remove it from the new cache; ok if
            // we end up removing another instance with same id
            if (_news != null)
                _news.remove(id);

            // and put into main cache now that id is asssigned
            orig = (StateManagerImpl) _main.put(sm.getObjectId(), sm);
            if (orig != null && orig != sm && !orig.isDeleted()) {
                // put back orig and throw error
                _main.put(sm.getObjectId(), orig);
                throw new UserException(_loc.get("dup-oid-assign",
                    sm.getObjectId(), Exceptions.toString
                    (sm.getManagedInstance()))).setFailedObject
                    (sm.getManagedInstance()).setFatal(true);
            }
        }
View Full Code Here

                // get mapping for the current field
                pstate.field = field;
                owner = pstate.field.getDefiningMapping();
                if (pstate.field.getManagement()
                    != FieldMapping.MANAGE_PERSISTENT)
                    throw new UserException(_loc.get("non-pers-field",
                        pstate.field));

                // find the most-derived type between the declared relation
                // type and the field's owner, and join from that type to
                // the lesser derived type
View Full Code Here

    }

    public Expression matches(Value v1, Value v2,
        String single, String multi, String esc) {
        if (!(v2 instanceof Const))
            throw new UserException(_loc.get("const-only", "matches"));
        return new MatchesExpression((Val) v1, (Const) v2, single, multi,
            esc != null ? esc : _type.getMappingRepository().
                getDBDictionary().searchStringEscape);
    }
View Full Code Here

            return null;
        Unique uniqueConstraint = new Unique();
        uniqueConstraint.setName(name);
        for (int i=0; i<columnNames.length; i++) {
            if (StringUtils.isEmpty(columnNames[i]))
                throw new UserException(_loc.get("empty-unique-column",
                    Arrays.toString(columnNames), cm));
            Column column = new Column();
            column.setName(columnNames[i]);
            uniqueConstraint.addColumn(column);
        }
View Full Code Here

    @Override
    public void setNull(PreparedStatement stmnt, int idx, int colType,
        Column col)
        throws SQLException {
        if ((colType == Types.CLOB || colType == Types.BLOB) && col.isNotNull())
            throw new UserException(_loc.get("null-blob-in-not-nullable", toDBName(col
                .getFullDBIdentifier())));
        if (colType == Types.BLOB && _driverBehavior == BEHAVE_ORACLE)
            stmnt.setBlob(idx, getEmptyBlob());
        else if (colType == Types.CLOB && _driverBehavior == BEHAVE_ORACLE
            && !col.isXML())
View Full Code Here

                dict = (DBDictionary) AccessController.doPrivileged(
                        J2DoPrivHelper.newInstanceAction(c));
            } catch (Exception e) {
                if (e instanceof PrivilegedActionException)
                    e = ((PrivilegedActionException) e).getException();
                throw new UserException(e).setFatal(true);
            }
        } catch (Exception e) {
            if (e instanceof PrivilegedActionException)
                e = ((PrivilegedActionException) e).getException();
            throw new UserException(e).setFatal(true);
        }

        // warn if we could not locate the appropriate dictionary
        Log log = conf.getLog(JDBCConfiguration.LOG_JDBC);
        if (log.isWarnEnabled() && dict.getClass() == DBDictionary.class)
View Full Code Here

TOP

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

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.