Package org.apache.cayenne

Examples of org.apache.cayenne.CayenneRuntimeException


                }
            }

            // sanity check
            if (idIndices[i] == -1) {
                throw new CayenneRuntimeException("PK column is not part of result row: "
                        + pk.getName());
            }
        }
    }
View Full Code Here


        // locate field
        try {
            field = lookupFieldInHierarchy(beanClass, propertyName);
        }
        catch (SecurityException e) {
            throw new CayenneRuntimeException("Error accessing field '"
                    + propertyName
                    + "' in class: "
                    + beanClass.getName(), e);
        }
        catch (NoSuchFieldException e) {
            throw new CayenneRuntimeException("No field '"
                    + propertyName
                    + "' is defined in class: "
                    + beanClass.getName(), e);
        }

        // set accessability
        if (!Util.isAccessible(field)) {
            field.setAccessible(true);
        }

        if (propertyType != null) {

            // check that the field is of expected class...
            if (!field.getType().isAssignableFrom(propertyType)) {

                // allow primitive to object conversions...
                if (!PropertyUtils.normalizeType(field.getType()).isAssignableFrom(
                        PropertyUtils.normalizeType(propertyType))) {
                    throw new CayenneRuntimeException("Expected property type '"
                            + propertyType.getName()
                            + "', got '"
                            + field.getType().getName()
                            + "'. Property: '"
                            + beanClass.getName()
View Full Code Here

        }
        else if (size == 1) {
            return dataDomains.values().iterator().next();
        }
        else {
            throw new CayenneRuntimeException(
                    "More than one domain is configured; use 'getDomain(String name)' instead.");
        }
    }
View Full Code Here

     * adapterFactory is null, default factory is used.
     */
    public AutoAdapter(DbAdapterFactory adapterFactory, DataSource dataSource) {
        // sanity check
        if (dataSource == null) {
            throw new CayenneRuntimeException("Null dataSource");
        }

        this.adapterFactory = adapterFactory != null
                ? adapterFactory
                : createDefaultFactory();
View Full Code Here

                    // ignore...
                }
            }
        }
        catch (SQLException e) {
            throw new CayenneRuntimeException("Error detecting database type: "
                    + e.getLocalizedMessage(), e);
        }

        if (adapter == null) {
            QueryLogger.log("Failed to detect database type, using default adapter");
View Full Code Here

        }

        QueryEngine node = domain.lookupDataNode(map);

        if (node == null) {
            throw new CayenneRuntimeException("No DataNode exists for DataMap " + map);
        }

        return node;
    }
View Full Code Here

    ChildDiffLoader(ObjectContext context) {
        this.context = context;
    }

    public void nodeIdChanged(Object nodeId, Object newId) {
        throw new CayenneRuntimeException("Not supported");
    }
View Full Code Here

            Persistent dataObject = null;
            try {
                dataObject = (Persistent) entity.getJavaClass().newInstance();
            }
            catch (Exception ex) {
                throw new CayenneRuntimeException("Error instantiating object.", ex);
            }

            dataObject.setObjectId(id);
            context.registerNewObject(dataObject);
        }
View Full Code Here

        setExternalChange(Boolean.TRUE);
        try {
            descriptor.getProperty(property).writeProperty(object, null, newValue);
        }
        catch (Exception e) {
            throw new CayenneRuntimeException("Error setting property: " + property, e);
        }
        finally {
            setExternalChange(Boolean.FALSE);
        }
    }
View Full Code Here

        Query query = new ObjectIdQuery((ObjectId) nodeId);
        QueryResponse response = context.getChannel().onQuery(context, query);
        List objects = response.firstList();

        if (objects.size() == 0) {
            throw new CayenneRuntimeException("No object for ID exists: " + nodeId);
        }
        else if (objects.size() > 1) {
            throw new CayenneRuntimeException(
                    "Expected zero or one object, instead query matched: "
                            + objects.size());
        }

        return (Persistent) objects.get(0);
View Full Code Here

TOP

Related Classes of org.apache.cayenne.CayenneRuntimeException

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.