Package org.datanucleus

Examples of org.datanucleus.ObjectManager$ObjectManagerListener


    public void checkConsistency()
    {
        Set entries = fieldChanges.entrySet();
        Iterator iter = entries.iterator();
        AbstractClassMetaData cmd = ownerSM.getClassMetaData();
        ObjectManager om = ownerSM.getObjectManager();
        while (iter.hasNext())
        {
            Map.Entry entry = (Map.Entry)iter.next();
            int fieldNumber = ((Integer)entry.getKey()).intValue();
            AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
            ClassLoaderResolver clr = om.getClassLoaderResolver();
            Object oldValue = entry.getValue();
            int relationType = mmd.getRelationType(clr);
            if (relationType == Relation.ONE_TO_ONE_BI)
            {
                // 1-1 bidirectional
View Full Code Here


    public void process()
    {
        Set entries = fieldChanges.entrySet();
        Iterator iter = entries.iterator();
        AbstractClassMetaData cmd = ownerSM.getClassMetaData();
        ObjectManager om = ownerSM.getObjectManager();
        while (iter.hasNext())
        {
            Map.Entry entry = (Map.Entry)iter.next();
            int fieldNumber = ((Integer)entry.getKey()).intValue();
            AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
            ClassLoaderResolver clr = om.getClassLoaderResolver();
            Object oldValue = entry.getValue();
            int relationType = mmd.getRelationType(clr);
            if (relationType == Relation.ONE_TO_ONE_BI)
            {
                // 1-1 bidirectional
View Full Code Here

        {
            // Check there are no active transactions before closing any PM
            Set<JDOUserException> exceptions = new HashSet<JDOUserException>();
            for (JDOPersistenceManager pm : pmCache)
            {
                ObjectManager om = pm.getObjectManager();
                if (om.getTransaction().isActive())
                {
                    // Note: we replicate the exception that would have come from pm.close() when tx active
                    TransactionActiveOnCloseException tae = new TransactionActiveOnCloseException(om);
                    exceptions.add(new JDOUserException(tae.getMessage(), pm));
                }
View Full Code Here

    return false;
  }

  public FieldManager getFieldManagerForResultProcessing(StateManager sm, Object obj,
                                                         StatementClassMapping resultMappings) {
    ObjectManager om = sm.getObjectManager();
    Class<?> cls = om.getClassLoaderResolver().classForName(sm.getClassMetaData().getFullClassName());
    Object internalKey = EntityUtils.idToInternalKey(sm.getObjectManager(), cls, obj, true);
    // Need to provide this to the field manager in the form of the pk
    // of the type: Key, Long, encoded String, or unencoded String
    return new KeyOnlyFieldManager(internalKey);
  }
View Full Code Here

  private void put(List<PutState> putStateList) {
    if (putStateList.isEmpty()) {
      return;
    }
    DatastoreTransaction txn = null;
    ObjectManager om = null;
    List<Entity> entityList = Utils.newArrayList();
    for (PutState putState : putStateList) {
      if (txn == null) {
        txn = EntityUtils.getCurrentTransaction(putState.sm.getObjectManager());
      }
View Full Code Here

    return false;
  }

  public FieldManager getFieldManagerForResultProcessing(StateManager sm, Object obj,
                                                         StatementClassMapping resultMappings) {
    ObjectManager om = sm.getObjectManager();
    Class<?> cls = om.getClassLoaderResolver().classForName(sm.getClassMetaData().getFullClassName());
    Object internalKey = EntityUtils.idToInternalKey(sm.getObjectManager(), cls, obj, true);
    // Need to provide this to the field manager in the form of the pk
    // of the type: Key, Long, encoded String, or unencoded String
    return new KeyOnlyFieldManager(internalKey);
  }
View Full Code Here

   */
  public Object set(StateManager ownerSm, int index, Object element, boolean allowDependentField,
      ElementContainerStore ecs, Object obj) {
    DatastorePersistenceHandler handler = storeMgr.getPersistenceHandler();
    JavaTypeMapping orderMapping = ecs.getOrderMapping();
    ObjectManager om = ownerSm.getObjectManager();
    if (orderMapping != null) {
      StateManager childSm = om.findStateManager(element);
      // See DatastoreFieldManager.handleIndexFields for info on why this
      // absurdity is necessary.
      Entity childEntity =
          (Entity) childSm.getAssociatedValue(DatastorePersistenceHandler.ENTITY_WRITE_DELAYED);
      if (childEntity != null) {
        childSm.setAssociatedValue(DatastorePersistenceHandler.ENTITY_WRITE_DELAYED, null);
        childSm.setAssociatedValue(ecs.getOrderMapping(), index);
        handler.insertObject(childSm);
      }
    }

    if (ecs.getOwnerMemberMetaData().getCollection().isDependentElement() &&
        allowDependentField && obj != null) {
      ownerSm.getObjectManager().deleteObjectInternal(obj);
    }
    if (!om.getTransaction().isActive()) {
      om.getTransaction().addTransactionEventListener(
          new ForceFlushPreCommitTransactionEventListener(ownerSm));
    }
    return obj;
  }
View Full Code Here

      // we don't support unowned relationships yet
      throw new UnsupportedOperationException(
          "Non-owned relationships are not currently supported.");
    } else {
      // first we need to delete the element
      ObjectManager om = sm.getObjectManager();
      Object element = fkListStore.get(sm, index);
      StateManager elementStateManager = om.findStateManager(element);
      DatastorePersistenceHandler handler = storeMgr.getPersistenceHandler();
      // the delete call can end up cascading back here, so set a thread-local
      // to make sure we don't do it more than once
      removing.set(true);
      try {
View Full Code Here

    return false;
  }

  public FieldManager getFieldManagerForResultProcessing(StateManager sm, Object obj,
                                                         StatementClassMapping resultMappings) {
    ObjectManager om = sm.getObjectManager();
    Class<?> cls = om.getClassLoaderResolver().classForName(sm.getClassMetaData().getFullClassName());
    Object internalKey = EntityUtils.idToInternalKey(sm.getObjectManager(), cls, obj, true);
    // Need to provide this to the field manager in the form of the pk
    // of the type: Key, Long, encoded String, or unencoded String
    return new KeyOnlyFieldManager(internalKey);
  }
View Full Code Here

  static void checkForParentSwitch(Object child, StateManager parentSM) {
    if (child == null) {
      return;
    }
    ObjectManager om = parentSM.getObjectManager();
    ApiAdapter apiAdapter = om.getApiAdapter();

    StateManager childStateMgr = om.findStateManager(child);
    if (apiAdapter.isNew(child) &&
        (childStateMgr == null ||
         childStateMgr.getAssociatedValue(EntityUtils.getCurrentTransaction(om)) == null)) {
      // This condition is difficult to get right.  An object that has been persisted
      // (and therefore had its primary key already established) may still be considered
View Full Code Here

TOP

Related Classes of org.datanucleus.ObjectManager$ObjectManagerListener

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.