Package org.datanucleus.exceptions

Examples of org.datanucleus.exceptions.NucleusObjectNotFoundException


                    ResultSet rs = sqlControl.executeStatementQuery(mconn, textStmt, ps);
                    try
                    {
                        if (!rs.next())
                        {
                            throw new NucleusObjectNotFoundException("No such database row", sm.getInternalObjectId());
                        }

                        int jdbcMajorVersion = ((DatabaseAdapter)datastoreContainer.getStoreManager().getDatastoreAdapter()).getDriverMajorVersion();
                        if (jdbcMajorVersion < 10)
                        {
View Full Code Here


                    try
                    {
                        if (!rs.next())
                        {
                            throw new NucleusObjectNotFoundException("No such database row", sm.getInternalObjectId());
                        }

                        int jdbcMajorVersion = ((DatabaseAdapter)storeMgr.getDatastoreAdapter()).getDriverMajorVersion();
                        if (jdbcMajorVersion < 10)
                        {
View Full Code Here

        ClassLoaderResolver clr = myOM.getClassLoaderResolver();
        String className = getStoreManager().getClassNameForObjectID(myID, clr, myOM);
        if (className == null)
        {
            // className is null when id class exists, and object has been validated and doesn't exist.
            throw new NucleusObjectNotFoundException(LOCALISER.msg("026013", myOM.getIdentityAsString(myID)), myID);
        }
        else if (!cmd.getFullClassName().equals(className))
        {
            Class pcClass;
            try
View Full Code Here

        String className = getStoreManager().getClassNameForObjectID(myID, myOM.getClassLoaderResolver(), myOM);
        if (!myPC.getClass().getName().equals(className))
        {
            myOM.removeObjectFromCache(myID);
            myOM.removeObjectFromLevel2Cache(myID);
            throw new NucleusObjectNotFoundException("Object with id " + myID +
                " was created without validating of type " + myPC.getClass().getName() +
                " but is actually of type " + className);
        }
        flags &= ~FLAG_NEED_INHERITANCE_VALIDATION;
    }
View Full Code Here

                        {
                            if (!rs.next())
                            {
                                NucleusLogger.DATASTORE_RETRIEVE.info(LOCALISER.msg("050018",
                                    sm.getInternalObjectId()));
                                throw new NucleusObjectNotFoundException("No such database row", sm.getInternalObjectId());
                            }
                        }
                        finally
                        {
                            rs.close();
View Full Code Here

                                if (NucleusLogger.DATASTORE_RETRIEVE.isInfoEnabled())
                                {
                                    NucleusLogger.DATASTORE_RETRIEVE.info(LOCALISER.msg("050018",
                                        sm.getInternalObjectId()));
                                }
                                throw new NucleusObjectNotFoundException("No such database row",
                                    sm.getInternalObjectId());
                            }

                            // Copy the results into the object
                            sm.replaceFields(memberNumbersToFetch,
View Full Code Here

                        expression = "/" + doc.getDocumentElement().getNodeName();
                    }
                    else
                    {
                        // No root, so can't have an object
                        throw new NucleusObjectNotFoundException(LOCALISER.msg("XML.Object.NotFound",
                            sm.toPrintableID(), sm.getInternalObjectId(), expression));
                    }
                }
                expression += "/" + XMLUtils.getElementNameForClass(acmd);
                String[] pk = acmd.getPrimaryKeyMemberNames();
                for (int i=0; i<pk.length; i++)
                {
                    AbstractMemberMetaData pkmmd = acmd.getMetaDataForMember(pk[i]);
                    String pkElement = XMLUtils.getElementNameForMember(pkmmd, FieldRole.ROLE_FIELD);
                    Object obj = sm.provideField(acmd.getPKMemberPositions()[i]);
                    expression += "/" + pkElement + "/text()='" + obj.toString() + "'";
                }

                isStored = (Boolean) xpath.evaluate(expression, doc, XPathConstants.BOOLEAN);
            }
            catch (Exception e)
            {
                throw new NucleusObjectNotFoundException(LOCALISER.msg("XML.Object.NotFound",
                    sm.toPrintableID(), sm.getInternalObjectId(), expression));
            }
            finally
            {
                mconn.release();
            }

            if (NucleusLogger.DATASTORE_RETRIEVE.isDebugEnabled())
            {
                NucleusLogger.DATASTORE_RETRIEVE.debug(LOCALISER.msg("XML.ExecutionTime",
                    (System.currentTimeMillis() - startTime)));
            }

            if (!isStored)
            {
                throw new NucleusObjectNotFoundException(LOCALISER.msg("XML.Object.NotFound",
                    sm.toPrintableID(), sm.getInternalObjectId(), expression));
            }
        }
    }
View Full Code Here

            {
                // Try to derive the class name from the id, since not provided
                className = getStoreManager().getClassNameForObjectID(id, clr, this);
                if (className == null)
                {
                    throw new NucleusObjectNotFoundException(LOCALISER.msg("010026"), id);
                }
                if (id instanceof OID)
                {
                    // Try again using the derived class name
                    id = OIDFactory.getInstance(getNucleusContext(), className, ((OID)id).getKeyValue());
View Full Code Here

                    throw new NucleusUserException(LOCALISER.msg("010006"));
                }
                else if (id instanceof DatastoreUniqueOID)
                {
                    // Should have been found using "persistenceHandler.findObject()"
                    throw new NucleusObjectNotFoundException(LOCALISER.msg("010026"), id);
                }
                else if (api.isDatastoreIdentity(id) || api.isSingleFieldIdentity(id))
                {
                    // OID or SingleFieldIdentity, so check that the implied class is managed
                    originalClassName = getStoreManager().manageClassForIdentity(id, clr);
                }
                else
                {
                    // We dont know the object class so try to deduce it from what is known by the StoreManager
                    originalClassName = getStoreManager().getClassNameForObjectID(id, clr, this);
                    checkedClassName = true;
                }

                if (validate)
                {
                    // Validate the inheritance level
                    className =
                        (checkedClassName ? originalClassName : getStoreManager().getClassNameForObjectID(id, clr, this));
                    if (className == null)
                    {
                        throw new NucleusObjectNotFoundException(LOCALISER.msg("010026"), id);
                    }

                    if (originalClassName != null && !originalClassName.equals(className))
                    {
                        // Inheritance check implies different inheritance level, so retry
View Full Code Here

                {
                    throw new NucleusUserException(LOCALISER.msg("010006"));
                }
                else if (id instanceof DatastoreUniqueOID)
                {
                    throw new NucleusObjectNotFoundException(LOCALISER.msg("010026"), id);
                }
                else if (api.isDatastoreIdentity(id) || api.isSingleFieldIdentity(id))
                {
                    // DatastoreIdentity or SingleFieldIdentity, so check that the implied class is managed
                    originalClassName = getStoreManager().manageClassForIdentity(id, clr);
                }
                else if (objectClassName != null)
                {
                    // Object class name specified so use that directly
                    originalClassName = objectClassName;
                }
                else
                {
                    // We dont know the object class so try to deduce it from what is known by the StoreManager
                    originalClassName = getStoreManager().getClassNameForObjectID(id, clr, this);
                    checkedClassName = true;
                }

                if (checkInheritance)
                {
                    // Verify if correct class inheritance level is set
                    if (!checkedClassName)
                    {
                        className = getStoreManager().getClassNameForObjectID(id, clr, this);
                    }
                    else
                    {
                        // We just checked the name of the class in the section above so just use that
                        className = originalClassName;
                    }

                    if (className == null)
                    {
                        throw new NucleusObjectNotFoundException(LOCALISER.msg("010026"), id);
                    }

                    if (originalClassName != null && !originalClassName.equals(className))
                    {
                        // Inheritance checking has found a different inherited
                        // object with this identity so create new id
                        if (api.isDatastoreIdentity(id))
                        {
                            // Create new OID using correct target class and recheck the cache
                            id = OIDFactory.getInstance(getNucleusContext(), className, ((OID)id).getKeyValue());
                            pc = getObjectFromCache(id);
                        }
                        else if (api.isSingleFieldIdentity(id))
                        {
                            // Create new SingleFieldIdentity using correct targetClass and recheck the cache
                            id = api.getNewSingleFieldIdentity(id.getClass(), clr.classForName(className),
                                    api.getTargetKeyForSingleFieldIdentity(id));
                            pc = getObjectFromCache(id);
                        }
                    }
                }
                else
                {
                    className = originalClassName;
                }

                if (pc == null)
                {
                    // Still not found, so create a Hollow instance with supplied PK values if possible
                    try
                    {
                        Class pcClass = clr.classForName(className, (id instanceof OID) ? null : id.getClass().getClassLoader());
                        if (Modifier.isAbstract(pcClass.getModifiers()))
                        {
                            // This class is abstract so impossible to have an instance of this type
                            throw new NucleusObjectNotFoundException(LOCALISER.msg("010027",
                                getIdentityAsString(id), className));
                        }

                        sm = (StateManager) ObjectProviderFactory.newForHollow(this, pcClass, id);
                        pc = sm.getObject();
View Full Code Here

TOP

Related Classes of org.datanucleus.exceptions.NucleusObjectNotFoundException

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.