Package org.jpox.exceptions

Examples of org.jpox.exceptions.JPOXUserException


     */
    public void initialiseForHollowAppId(FieldValues fv, Class pcClass)
    {
        if (cmd.getIdentityType() != IdentityType.APPLICATION)
        {
            throw new JPOXUserException("This constructor is only for objects using application identity.").setFatal();
        }

        myLC = myOM.getOMFContext().getApiAdapter().getLifeCycleState(LifeCycleState.HOLLOW);
        jdoDfgFlags = PersistenceCapable.LOAD_REQUIRED;
        myPC = HELPER.newInstance(pcClass, this); // Create new PC
        if (myPC == null)
        {
            if (!HELPER.getRegisteredClasses().contains(pcClass))
            {
                // probably never will get here, as JDOImplHelper.newInstance() internally already throws
                // JDOFatalUserException when class is not registered
                throw new JPOXUserException(LOCALISER.msg("026018", pcClass.getName())).setFatal();
            }
            else
            {
                // Provide advisory information since we can't create an instance of this class, so maybe they
                // have an error in their data ?
                throw new JPOXUserException(LOCALISER.msg("026019", pcClass.getName())).setFatal();
            }
        }

        loadFieldValues(fv); // as a minimum the PK fields are loaded here

View Full Code Here


                parseChar(',');
            }
            String name = parseName();
            if( name == null && !parseEOS())
            {
                throw new JPOXUserException("Invalid characters found \""+remaining()+"\" at position "+this.getIndex()+" of text \""+input+"\"");
            }
            return name;
        }
View Full Code Here

                                myPC.jdoProvideField(fieldNumber);
                                PersistenceCapable pkFieldPC =
                                    (PersistenceCapable) ((SingleValueFieldManager) currFM).fetchObjectField(fieldNumber);
                                if (pkFieldPC == null)
                                {
                                    throw new JPOXUserException(
                                        LOCALISER.msg("026016", fmd.getFullFieldName()));
                                }
                                if (!myOM.getApiAdapter().isPersistent(pkFieldPC))
                                {
                                    // Can cause the insert of our object being managed by this SM via flush() when bidir relation
View Full Code Here

                cmd = myOM.getMetaDataManager().getMetaDataForClass(pcClass, getObjectManager().getClassLoaderResolver());
            }
            catch (ClassNotResolvedException e)
            {
                JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("026014", myID));
                throw new JPOXUserException(LOCALISER.msg("026014", myID), e);
            }
            if (cmd == null)
            {
                throw new JPOXUserException(LOCALISER.msg("026012", pcClass)).setFatal();
            }
            if (cmd.getIdentityType() != IdentityType.APPLICATION)
            {
                throw new JPOXUserException("This method should only be used for objects using application identity.").setFatal();
            }
            myFP = myOM.getFetchPlan().manageFetchPlanForClass(cmd);

            initialiseFieldInformation();

            // Create new PC at right inheritance level
            myPC = HELPER.newInstance(pcClass, this);
            if (myPC == null)
            {
                throw new JPOXUserException(LOCALISER.msg("026018", cmd.getFullClassName())).setFatal();
            }

            // Note that this will mean the fields are loaded twice (loaded earlier in this method)
            // and also that postLoad will be called twice
            loadFieldValues(fv);
View Full Code Here

                    else if (cmd.usesSingleFieldIdentityClass())
                    {
                        if (this.provideField(fieldNumber) == null)
                        {
                            // SingleFieldIdentity field has not had its value set (by user, or by value-strategy)
                            throw new JPOXUserException(LOCALISER.msg("026017",
                                cmd.getFullClassName(), fmd.getName())).setFatal();
                        }
                    }
                }
            }
View Full Code Here

            AbstractMemberMetaData mmd = getClassMetaData().getMetaDataForMember(fieldName);
            loadedFields[mmd.getAbsoluteFieldNumber()] = false;
        }
        else
        {
            throw new JPOXUserException("Cannot unload field/property of embedded object");
        }
    }
View Full Code Here

                disconnect();

                if (!toCheckPC.jdoIsDetached())
                {
                    // Sanity check on the objects detached state
                    throw new JPOXUserException(LOCALISER.msg("026025", toCheckPC.getClass().getName(), toCheckID));
                }
            }
            else
            {
                // Make the object transient
View Full Code Here

     */
    public Object detachCopy(FetchPlanState state)
    {
        if (myLC.isDeleted())
        {
            throw new JPOXUserException(
                LOCALISER.msg("026023", myPC.getClass().getName(), myID));
        }
        if (myOM.getApiAdapter().isDetached(myPC))
        {
            throw new JPOXUserException(
                LOCALISER.msg("026024", myPC.getClass().getName(), myID));
        }
        if (dirty)
        {
            myOM.flushInternal(false);
        }
        if (detaching)
        {
            // Object in the process of detaching (recursive) so return the object which will be the detached object
            return referencedPC;
        }

        PersistenceCapable detachedPC = myPC.jdoNewInstance(this);
        referencedPC = detachedPC;

        // Check if detachable ... if so then we detach a copy, otherwise we return a transient copy
        boolean detachable = myOM.getApiAdapter().isDetachable(myPC);

        // make sure a detaching PC is not read by another thread while we are detaching
        synchronized (referencedPC)
        {
            if (detachable)
            {
                if (JPOXLogger.PERSISTENCE.isDebugEnabled())
                {
                    JPOXLogger.PERSISTENCE.debug(LOCALISER.msg("010010", StringUtils.toJVMIDString(myPC),
                        "" + state.getCurrentFetchDepth(), StringUtils.toJVMIDString(detachedPC)));
                }

                // Call any "pre-detach" listeners
                getCallbackHandler().preDetach(myPC);
            }
            try
            {
                detaching = true;

                // Handle any field loading/unloading before the detach
                if ((myOM.getFetchPlan().getDetachmentOptions() & FetchPlan.DETACH_LOAD_FIELDS) != 0)
                {
                    // Load any unloaded fetch-plan fields
                    loadUnloadedFieldsInFetchPlan();
                }

                if (myLC == myOM.getOMFContext().getApiAdapter().getLifeCycleState(LifeCycleState.HOLLOW) ||
                    myLC == myOM.getOMFContext().getApiAdapter().getLifeCycleState(LifeCycleState.P_NONTRANS))
                {
                    // Migrate any HOLLOW/P_NONTRANS to P_CLEAN etc
                    myLC = myLC.transitionReadField(this, true);
                }

                // Create a SM for our copy object
                JDOStateManagerImpl smDetachedPC = new JDOStateManagerImpl(myOM, cmd);
                smDetachedPC.initialiseForDetached(detachedPC, getExternalObjectId(myPC), getVersion(myPC));
                detachedPC.jdoReplaceStateManager(smDetachedPC);
                smDetachedPC.referencedPC = myPC;

                smDetachedPC.replaceFields(getFieldsNumbersToDetach(), new DetachFieldManager(this, getSecondClassMutableFields(),
                    myFP, state, true));

                smDetachedPC.referencedPC = null;
                if (detachable)
                {
                    // Update the object with its detached state - not to be confused with the "state" object above
                    detachedPC.jdoReplaceFlags();
                    ((Detachable)detachedPC).jdoReplaceDetachedState();
                }
                else
                {
                    smDetachedPC.makeTransient(null);
                }

                // Remove its StateManager since now detached or transient
                detachedPC.jdoReplaceStateManager(null);
            }
            catch (Exception e)
            {
                // What could possible be thrown here ?
                JPOXLogger.PERSISTENCE.debug("DETACH ERROR : Error thrown while detaching " +
                    StringUtils.toJVMIDString(myPC) + " (id=" + myID + ")", e);
            }
            finally
            {
                detaching = false;
                referencedPC = null;
            }

            if (detachable && !myOM.getApiAdapter().isDetached(detachedPC))
            {
                // Sanity check on the objects detached state
                throw new JPOXUserException(LOCALISER.msg("026025", detachedPC.getClass().getName(), myID));
            }

            if (detachable)
            {
                // Call any "post-detach" listeners
View Full Code Here

     */
    private void internalDeletePersistent()
    {
        if (isDeleting())
        {
            throw new JPOXUserException(LOCALISER.msg("026008"));
        }

        activity = ActivityState.DELETING;
        try
        {
View Full Code Here

                    });

        }
        catch (SecurityException e)
        {
            throw new JPOXUserException(e.getMessage());

        }
        catch (JPOXException jpe)
        {
            if (myOM.getStateManagerById(myID) == this)
View Full Code Here

TOP

Related Classes of org.jpox.exceptions.JPOXUserException

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.