Package org.datanucleus

Examples of org.datanucleus.ObjectManager


                    storeManager.getMetaDataManager().getMetaDataForClass(ammd.getType(),
                                                        objectProvider.getExecutionContext().getClassLoaderResolver());
                if (acmd != null) {
                    actualValue = PersistenceUtils.getMemberValue(acmd, acmd.getPKMemberPositions()[0], value);
                    if (actualValue == null) {
                        ObjectManager om = ((ObjectProviderImpl) objectProvider).getStateManager().getObjectManager();
                        if (((ForceObjectManagerImpl) om).isInAllOrNothingMode()) {
                            /**
                             * This is instance of AllOrNothing transaction
                             * Since the parent object has not been saved to the db yet
                             * we do not have an id yet so we link objects by extId
View Full Code Here


        };
    }
   
    @Test(dataProvider = "javaFieldProvider")
    public void testGetForceApiName(String testName, Class entityClass, String memberName, String expectedApiName) {
        ObjectManager om = (ObjectManager) em.getDelegate();

        AbstractClassMetaData acmd = om.getMetaDataManager().getMetaDataForClass(entityClass, null);
        AbstractMemberMetaData ammd = acmd.getMetaDataForMember(memberName);
       
        String apiName = PersistenceUtils.getForceApiName(ammd, om.getOMFContext());
        assertEquals(apiName, expectedApiName, "Unexpected API name");
    }
View Full Code Here

        }
    }

    protected void cleanSchema() throws Exception {
        if (em == null) createPrimaryEntityManager();
        ObjectManager om = (ObjectManager) em.getDelegate();

        // Get the EntityManager's PartnerConnection
        ConnectionFactory connFactory = om.getStoreManager().getConnectionManager().lookupConnectionFactory("force");
        ForceManagedConnection mconn = (ForceManagedConnection) connFactory.createManagedConnection(null, null);
        SfdcSchemaUtil.cleanSchema(mconn);
    }
View Full Code Here

    protected void testTeardown() throws Exception {
        cleanSchema();
    }

    protected void cleanSchema() throws Exception {
        ObjectManager om = (ObjectManager) entityManager.getDelegate();
        // Get the EntityManager's PartnerConnection
        ConnectionFactory connFactory = om.getStoreManager().getConnectionManager().lookupConnectionFactory("force");
        ForceManagedConnection mconn = (ForceManagedConnection) connFactory.createManagedConnection(null, null);
        // cleanup schema via destructive changes
        SfdcSchemaUtil.cleanSchema(mconn);
    }
View Full Code Here

  public boolean getUpdateElementFk(StateManager sm, Object element, Object owner, int index,
      ElementContainerStore ecs) {
    JavaTypeMapping orderMapping = ecs.getOrderMapping();
    if (orderMapping != null) {
      DatastorePersistenceHandler handler = storeMgr.getPersistenceHandler();
      ObjectManager om = sm.getObjectManager();
      StateManager childSm = om.findStateManager(element);
      Entity childEntity = handler.getAssociatedEntityForCurrentTransaction(childSm);
      orderMapping.setObject(sm.getObjectManager(), childEntity, new int[1], index);
      handler.put(om, childEntity);
      return true;
    }
View Full Code Here

  public <T> List<T> toJPAResult(EntityManager em, Class<T> cls, QueryResultIterable<Entity> queryResultIterable) {
    return toJPAResult(em, cls, queryResultIterable, null);
  }

  private <T> List<T> toJPAResult(EntityManager em, Class<T> cls, Iterable<Entity> queryResultIterable, Cursor endCursor) {
    ObjectManager om = ((EntityManagerImpl) em).getObjectManager();
    return toPojoResult(om, cls, queryResultIterable, endCursor);
  }
View Full Code Here

     * @param elements The elements to process
     * @param elementsWithoutIdentity Whether the elements have their own identity
     */
    public static void attachForCollection(StateManager ownerSM, Object[] elements, boolean elementsWithoutIdentity)
    {
        ObjectManager om = ownerSM.getObjectManager();
        ApiAdapter api = om.getApiAdapter();
        for (int i = 0; i < elements.length; i++)
        {
            if (api.isPersistable(elements[i]))
            {
                Object attached = om.getAttachedObjectForId(api.getIdForObject(elements[i]));
                if (attached == null)
                {
                    // Not yet attached so attach
                    om.attachObject(elements[i], elementsWithoutIdentity);
                }
            }
        }
    }
View Full Code Here

     * @param keysWithoutIdentity Whether the keys have their own identity
     * @param valuesWithoutIdentity Whether the values have their own identity
     */
    public static void attachForMap(StateManager ownerSM, Set entries, boolean keysWithoutIdentity, boolean valuesWithoutIdentity)
    {
        ObjectManager om = ownerSM.getObjectManager();
        ApiAdapter api = om.getApiAdapter();
        for (Iterator it = entries.iterator(); it.hasNext();)
        {
            Map.Entry entry = (Map.Entry) it.next();
            Object val = entry.getValue();
            Object key = entry.getKey();
            if (api.isPersistable(key))
            {
                Object attached = om.getAttachedObjectForId(api.getIdForObject(key));
                if (attached == null)
                {
                    // Not yet attached so attach
                    ownerSM.getObjectManager().attachObject(key, keysWithoutIdentity);
                }
            }
            if (api.isPersistable(val))
            {
                Object attached = om.getAttachedObjectForId(api.getIdForObject(val));
                if (attached == null)
                {
                    // Not yet attached so attach
                    ownerSM.getObjectManager().attachObject(val, valuesWithoutIdentity);
                }
View Full Code Here

    {
        boolean persisted = false;
        ApiAdapter api = om.getApiAdapter();
        if (api.isPersistable(object))
        {
            ObjectManager objectOM = api.getObjectManager(object);
            if (objectOM != null && om != objectOM)
            {
                throw new NucleusUserException(LOCALISER.msg("023009", StringUtils.toJVMIDString(object)),
                    api.getIdForObject(object));
            }
View Full Code Here

  public boolean contains(StateManager ownerSM, Object element, AbstractCollectionStore acs) {
    // Since we only support owned relationships right now, we can
    // check containment simply by looking to see if the element's
    // Key contains the parent Key.
    ObjectManager om = ownerSM.getObjectManager();
    Key childKey = extractElementKey(om, element);
    // Child key can be null if element has not yet been persisted
    if (childKey == null || childKey.getParent() == null) {
      return false;
    }
    Key parentKey = EntityUtils.getPrimaryKeyAsKey(om.getApiAdapter(), ownerSM);
    return childKey.getParent().equals(parentKey);
  }
View Full Code Here

TOP

Related Classes of org.datanucleus.ObjectManager

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.