Examples of StateManagerImpl


Examples of org.apache.openjpa.kernel.StateManagerImpl

        BookId id = new BookId();
        id.setName(bookName);
        id.setLibrary(libName);

        Book persistedEntity = em.find(Book.class, id);
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();

        assertEquals(oid, JPAFacadeHelper.toOpenJPAObjectId(cmd, id));
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

        em.persist(entity);
        em.getTransaction().commit();
        em.clear();

        MedicalHistory4 persistedEntity = em.find(MedicalHistory4.class, id);
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();

        assertEquals(oid, JPAFacadeHelper.toOpenJPAObjectId(cmd, id));
    }
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

            // 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)
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

                return;
            PersistenceCapable pc = (PersistenceCapable)sm.
                fetchObject(getIndex());
            if (pc == null)
                return;
            StateManagerImpl pkSm = (StateManagerImpl)pc.
                pcGetStateManager();
            Object pkVal = getPKValue(pkSm);
            if (pkVal == null)
                return;
            setPKValue((StateManagerImpl)sm, pkVal);
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

            // 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)
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

            }
            if (autoAssignColNames != null)
                populateAutoAssignCols(stmnt, autoAssign, autoAssignColNames,
                    row);
            else {
                StateManagerImpl sm = (StateManagerImpl)row.getPrimaryKey();
                if (sm != null) {
                    ClassMapping meta = (ClassMapping)sm.getMetaData();
                    if (hasGeneratedKey(meta)) {
                        sm.setObjectId(ApplicationIds.create(
                            sm.getPersistenceCapable(), meta));
                    }
                }
            }
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, row.getFailedObject(), _dict);
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

            assertEquals(1, sql.size());
            String s = sql.get(0);
            assertFalse(s.contains("JOIN") && s.contains("join"));

            // Check to see how many fks(intermediate fields) we selected.
            StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) ee1).pcGetStateManager());
            ClassMetaData cmd =
                em.getConfiguration().getMetaDataRepositoryInstance().getMetaData(OptSelectEntity.class, null, true);
            int fks = 0;
            for (FieldMetaData fmd : cmd.getFields()) {
                if (smi.getIntermediate(fmd.getIndex()) != null) {
                    fks++;
                }
            }
            // We expected to find 2 FKs. One for each of the owners (lazyOneToOneOwner and eagerOneToOneOwner)
            assertEquals(2, fks);
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

                return;
            PersistenceCapable pc = (PersistenceCapable)sm.
                fetchObject(getIndex());
            if (pc == null)
                return;
            StateManagerImpl pkSm = (StateManagerImpl)pc.
                pcGetStateManager();
            Object pkVal = getPKValue(pkSm);
            if (pkVal == null)
                return;
            setPKValue((StateManagerImpl)sm, pkVal);
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

        Collection exceps = psMgr.getExceptions();
        Collection mappedByIdStates = new ArrayList();
        for (Iterator itr = states.iterator(); itr.hasNext();) {
            OpenJPAStateManager obj = (OpenJPAStateManager)itr.next();
            if (obj instanceof StateManagerImpl) {
                StateManagerImpl sm = (StateManagerImpl) obj;
                if (sm.getMappedByIdFields() != null)
                    mappedByIdStates.add(sm);
                else exceps = populateRowManager(sm, rowMgr, store, exceps,
                        customs);
            } else
                exceps = populateRowManager(obj, rowMgr, store, exceps,
                        customs);
        }

        // flush rows
        exceps = flush(rowMgr, psMgr, exceps);
       
        if (mappedByIdStates.size() != 0) {
            for (Iterator itr = mappedByIdStates.iterator(); itr.hasNext();) {
                StateManagerImpl sm = (StateManagerImpl) itr.next();
                exceps = populateRowManager(sm, rowMgr, store, exceps, customs);
            }
            // flush rows
            exceps = flush(rowMgr, psMgr, exceps);
        }
View Full Code Here

Examples of org.apache.openjpa.kernel.StateManagerImpl

            }
            if (autoAssignColNames != null)
                populateAutoAssignCols(stmnt, autoAssign, autoAssignColNames,
                    row);
            else {
                StateManagerImpl sm = (StateManagerImpl)row.getPrimaryKey();
                if (sm != null) {
                    ClassMapping meta = (ClassMapping)sm.getMetaData();
                    if (hasGeneratedKey(meta)) {
                        sm.setObjectId(ApplicationIds.create(
                            sm.getPersistenceCapable(), meta));
                    }
                }
            }
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, row.getFailedObject(), _dict);
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.