Examples of PersistenceCapable


Examples of org.apache.openjpa.enhance.PersistenceCapable

     * object is managed by another broker
     */
    protected StateManagerImpl getStateManagerImpl(Object obj,
        boolean assertThisContext) {
        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

Examples of org.apache.openjpa.enhance.PersistenceCapable

            _meta = sub;
        }
        if (cls.isInterface())
            cls = _meta.getInterfaceImpl();

        PersistenceCapable inst = PCRegistry.newInstance(cls, this, _oid, true);
        if (inst == null) {
            // the instance was null: check to see if the instance is
            // abstract (as can sometimes be the case when the
            // class discriminator strategy is not configured correctly)
            if (Modifier.isAbstract(cls.getModifiers()))
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

                throw new UserException(_loc.get("only-update-primitives"));
            }

            OpenJPAStateManager sm = _broker.getStateManager(ob);
            int i = fmd.getIndex();
            PersistenceCapable into = ImplHelper.toPersistenceCapable(ob,
                _broker.getConfiguration());

            // set the actual field in the instance
            int set = OpenJPAStateManager.SET_USER;
            switch (fmd.getDeclaredTypeCode()) {
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

        assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
        resetSQL();
        assertEquals(1, emps.size());
        // Verify the delay load entity is detached
        assertTrue(e instanceof PersistenceCapable);
        PersistenceCapable pc = (PersistenceCapable)e;
        assertTrue(pc.pcGetStateManager() instanceof DetachedStateManager);
        // verify a second SQL was not issued to get the size
        assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
       
        // add a employee to the collection and merge
        IEmployee e2 = createEmployee();
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

     */
    protected SliceInfo findSliceNames(OpenJPAStateManager sm, Object edata) {
        if (SliceImplHelper.isSliceAssigned(sm))
            return SliceImplHelper.getSliceInfo(sm);
        SliceInfo result = null;
        PersistenceCapable pc = sm.getPersistenceCapable();
        Object ctx = getContext();
        if (_conf.isReplicated(sm.getMetaData().getDescribedType())) {
            result = SliceImplHelper.getSlicesByPolicy(pc, _conf, ctx);
        } else {
            String origin = estimateSlice(sm, edata);
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

     */
    public static Object getIdentifier(OpenJPAEntityManagerFactory emf,
        Object entity) {

        if (entity instanceof PersistenceCapable) {
            PersistenceCapable pc = (PersistenceCapable)entity;
            // Per contract, if not managed by the owning emf, return null.
            if (emf != null) {
                if (!isManagedBy(emf, pc)) {
                    return null;
                }
            }
            StateManager sm = pc.pcGetStateManager();
           
            if (sm != null && sm instanceof OpenJPAStateManager) {
                OpenJPAStateManager osm = (OpenJPAStateManager)sm;
                return osm.getObjectId();               
            }
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

        // Assert a valid emf was provided, it is open, and the entity is PC
        if (emf == null || !emf.isOpen() || !ImplHelper.isManageable(entity)) {
            return false;
        }
        // Assert the context is a broker
        PersistenceCapable pc = (PersistenceCapable)entity;
        if (!(pc.pcGetGenericContext() instanceof Broker)) {
            return false;
        }
        // Assert the broker is available and open
        Broker broker = (Broker)pc.pcGetGenericContext();
        if (broker == null || broker.isClosed()) {
            return false;
        }
        // Assert the emf associated with the PC is the same as the provided emf
        OpenJPAEntityManagerFactory eemf = JPAFacadeHelper.toEntityManagerFactory(broker.getBrokerFactory());
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

            return LoadState.UNKNOWN;
        }
       
        // If the object has a state manager, call it directly.
        if (obj instanceof PersistenceCapable) {
            PersistenceCapable pc = (PersistenceCapable)obj;
            StateManager sm = pc.pcGetStateManager();
            if (sm != null && sm instanceof OpenJPAStateManager) {
                return isLoaded((OpenJPAStateManager)sm, attr, null);
            }
        }       
        return LoadState.UNKNOWN;
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

    private static OpenJPAStateManager getStateManager(Object obj) {       
        if (obj == null || !(obj instanceof PersistenceCapable)) {
            return null;
        }
       
        PersistenceCapable pc = (PersistenceCapable)obj;
        StateManager sm = pc.pcGetStateManager();
        if (sm == null || !(sm instanceof OpenJPAStateManager)) {
            return null;
        }
        return (OpenJPAStateManager)sm;
    }
View Full Code Here

Examples of org.apache.openjpa.enhance.PersistenceCapable

    private void setMappedBy(Object oid, OpenJPAStateManager sm, Object coll,
        Result res) {
        // for inverseEager field
        FieldMapping mappedByFieldMapping = field.getMappedByMapping();
        PersistenceCapable mappedByValue = null;
       
        if (mappedByFieldMapping != null) {
            ValueMapping val = mappedByFieldMapping.getValueMapping();
            ClassMetaData decMeta = val.getTypeMetaData();
            // this inverse field does not have corresponding classMapping
            // its value may be a collection/map etc.
            if (decMeta == null)
                return;
         
            StateManagerImpl owner = ((StateManagerImpl)sm).getObjectIdOwner();
            if (oid.equals(owner.getObjectId())) {
                mappedByValue = owner.getPersistenceCapable();
                res.setMappedByFieldMapping(mappedByFieldMapping);
                res.setMappedByValue(mappedByValue);
            } else if (coll instanceof Collection &&
                ((Collection) coll).size() > 0) {
                // Customer (1) <--> Orders(n)
                // coll contains the values of the toMany field (Orders)
                // get the StateManager of this toMany value
                // and find the value of the inverse mappedBy field (Customer)
                // for this toMacdny field
                PersistenceCapable pc = (PersistenceCapable)
                    ((Collection) coll).iterator().next();
                OpenJPAStateManager sm1 = (OpenJPAStateManager) pc.
                    pcGetStateManager();
               
                ClassMapping clm = ((ClassMapping) sm1.getMetaData());
                FieldMapping fm = (FieldMapping) clm.getField(
                    mappedByFieldMapping.getName());
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.