Examples of JDOUserException


Examples of javax.jdo.JDOUserException

        assertIsOpen();

        // Throw exception on incomplete input
        if (queryName == null)
        {
            throw new JDOUserException(LOCALISER_JDO.msg("011005", queryName, cls));
        }

        // Find the Query for the specified class
        ClassLoaderResolver clr = objectMgr.getClassLoaderResolver();
        QueryMetaData qmd = objectMgr.getMetaDataManager().getMetaDataForQuery(cls, clr, queryName);
        if (qmd == null)
        {
            throw new JDOUserException(LOCALISER_JDO.msg("011005", queryName, cls));
        }

        // Create the Query
        Query query = newQuery(qmd.getLanguage().toString(), qmd.getQuery());
        if (cls != null)
        {
            query.setClass(cls);
            if (!objectMgr.getStoreManager().managesClass(cls.getName()))
            {
                // Load the candidate class since not yet managed
                objectMgr.getStoreManager().addClass(cls.getName(), clr);
            }
        }

        // Optional args that should only be used with SQL
        if (qmd.getLanguage() == QueryLanguage.JDOQL && (qmd.isUnique() || qmd.getResultClass() != null))
        {
            throw new JDOUserException(LOCALISER_JDO.msg("011007", queryName));
        }
        if (qmd.isUnique())
        {
            query.setUnique(true);
        }
        if (qmd.getResultClass() != null)
        {
            // Set the result class, allowing for it being in the same package as the candidate
            Class resultCls = null;
            try
            {
                resultCls = clr.classForName(qmd.getResultClass());
            }
            catch (ClassNotResolvedException cnre)
            {
                try
                {
                    String resultClassName = cls.getPackage().getName() + "." + qmd.getResultClass();
                    resultCls = clr.classForName(resultClassName);
                }
                catch (ClassNotResolvedException cnre2)
                {
                    throw new JDOUserException(LOCALISER_JDO.msg("011008", queryName, qmd.getResultClass()));
                }
            }
            query.setResultClass(resultCls);
        }
View Full Code Here

Examples of javax.jdo.JDOUserException

    public synchronized Object getObjectById(Object id, boolean validate)
    {
        assertIsOpen();
        if (id == null)
        {
            throw new JDOUserException(LOCALISER.msg("010044"));
        }

        try
        {
            // Use inheritance checks according to persistence property
View Full Code Here

Examples of javax.jdo.JDOUserException

    public Collection getObjectsById(Collection oids, boolean validate)
    {
        assertIsOpen();
        if (oids == null || oids.size() == 0)
        {
            throw new JDOUserException(LOCALISER_JDO.msg("011002"));
        }

        Collection objects = new ArrayList(oids.size());
        Iterator iter = oids.iterator();
        while (iter.hasNext())
View Full Code Here

Examples of javax.jdo.JDOUserException

    public Object[] getObjectsById(Object[] oids, boolean validate)
    {
        assertIsOpen();
        if (oids == null)
        {
            throw new JDOUserException(LOCALISER_JDO.msg("011002"));
        }
        Object[] objects = new Object[oids.length];
        for (int i = 0; i < oids.length; i++)
        {
            // Just use getObjectById to get the object
View Full Code Here

Examples of javax.jdo.JDOUserException

        }

        if (objectMgr.getTransaction().getOptimistic())
        {
            // TODO Implement checkConsistency() for optimistic transactions
            throw new JDOUserException("checkConsistency() not yet implemented for optimistic transactions");
        }
        else
        {
            flush();
        }
View Full Code Here

Examples of javax.jdo.JDOUserException

        assertIsOpen();

        SequenceMetaData seqmd = objectMgr.getMetaDataManager().getMetaDataForSequence(objectMgr.getClassLoaderResolver(),sequenceName);
        if (seqmd == null)
        {
            throw new JDOUserException(LOCALISER.msg("017000", sequenceName));
        }

        Sequence seq = null;
        if (seqmd.getFactoryClass() != null)
        {
            // User has specified a factory class
            seq = getAbstractPersistenceManagerFactory().getSequenceForFactoryClass(seqmd.getFactoryClass());
            if (seq == null)
            {
                // Create a new instance of the factory class and obtain the Sequence
                Class factory = objectMgr.getClassLoaderResolver().classForName(seqmd.getFactoryClass());
                if (factory == null)
                {
                    throw new JDOUserException(LOCALISER.msg("017001", sequenceName, seqmd.getFactoryClass()));
                }

                Class[] argTypes = null;
                Object[] arguments = null;
                if (seqmd.getStrategy() != null)
                {
                    argTypes = new Class[2];
                    argTypes[0] = String.class;
                    argTypes[1] = String.class;
                    arguments = new Object[2];
                    arguments[0] = seqmd.getName();
                    arguments[1] = seqmd.getStrategy().toString();
                }
                else
                {
                    argTypes = new Class[1];
                    argTypes[0] = String.class;
                    arguments = new Object[1];
                    arguments[0] = seqmd.getName();
                }

                Method newInstanceMethod;
                try
                {
                    // Obtain the sequence from the static "newInstance(...)" method
                    newInstanceMethod = factory.getMethod("newInstance", argTypes);
                    seq = (Sequence) newInstanceMethod.invoke(null, arguments);
                }
                catch (Exception e)
                {
                    throw new JDOUserException(LOCALISER.msg("017002", seqmd.getFactoryClass(), e.getMessage()));
                }

                // Register the sequence with the PMF
                getAbstractPersistenceManagerFactory().addSequenceForFactoryClass(seqmd.getFactoryClass(), seq);
            }
View Full Code Here

Examples of javax.jdo.JDOUserException

     */
    protected void assertReadable(String operation)
    {
        if (!objectMgr.getTransaction().isActive() && !objectMgr.getTransaction().getNontransactionalRead())
        {
            throw new JDOUserException(LOCALISER_JDO.msg("011001", operation));
        }
    }
View Full Code Here

Examples of javax.jdo.JDOUserException

    protected void assertIsOpen()
    {
        if (!isOpen())
        {
            // TODO Should not throw JDOException when not using JDO
            throw new JDOUserException(LOCALISER.msg("052600"));
        }
    }
View Full Code Here

Examples of javax.jdo.JDOUserException

     */
    public void close()
    {
        if (!isAvailable)
        {
            throw new JDOUserException(LOCALISER.msg("046001"));
        }
        isAvailable = false;
        onClose.run();
    }
View Full Code Here

Examples of javax.jdo.JDOUserException

            {
                if (jpe.getNestedExceptions() != null)
                {
                    if (jpe.getFailedObject() != null)
                    {
                        return new JDOUserException(jpe.getMessage(), jpe.getNestedExceptions(), jpe.getFailedObject());
                    }
                    return new JDOUserException(jpe.getMessage(), jpe.getNestedExceptions());
                }
                else if (jpe.getFailedObject() != null)
                {
                    return new JDOUserException(jpe.getMessage(), jpe.getFailedObject());
                }
                else
                {
                    return new JDOUserException(jpe.getMessage(), jpe);
                }
            }
        }
        else if (jpe instanceof JPOXOptimisticException)
        {
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.