Package org.datanucleus.metadata

Examples of org.datanucleus.metadata.RelationType


      if (m.includeInUpdateStatement()) {
        if (fmd.isPrimaryKey()) {
        } else if (m instanceof PersistableMapping || m instanceof ReferenceMapping) {
          if (m.getNumberOfDatastoreMappings() == 0) {
            // Field storing a PC object with FK at other side
            RelationType relationType = fmd.getRelationType(clr);
            if (relationType == RelationType.ONE_TO_ONE_BI) {
              if (fmd.getMappedBy() != null) {
                // 1-1 bidirectional field without datastore column(s) (with single FK at other side)
                oneToOneNonOwnerFields.add(fmd);
              }
View Full Code Here


        }

        // Calculate if we need a FK adding due to a 1-N relationship TODO Remove this when no longer supporting old storageVersion
        // Note that we ignore any "join" setting since we don't use join tables
        boolean needsFKToContainerOwner = false;
        RelationType relationType = fmd.getRelationType(clr);
        if (relationType == RelationType.ONE_TO_MANY_BI) {
          /*AbstractMemberMetaData[] relatedMmds = fmd.getRelatedMemberMetaData(clr);
          if (fmd.getJoinMetaData() == null && relatedMmds[0].getJoinMetaData() == null) {*/
            needsFKToContainerOwner = true;
          /*}*/
 
View Full Code Here

    if (!isStorable(mmd)) {
      return;
    }

    ClassLoaderResolver clr = getClassLoaderResolver();
    RelationType relationType = mmd.getRelationType(clr);

    if (RelationType.isRelationSingleValued(relationType) && mmd.getEmbeddedMetaData() != null) {
      // Embedded persistable object
      ObjectProvider embeddedOP = getEmbeddedObjectProvider(mmd.getType(), fieldNumber, value);
View Full Code Here

            mapping instanceof SerialisedPCMapping ||
            mapping instanceof SerialisedReferenceMapping ||
            mapping instanceof PersistableMapping ||
            mapping instanceof InterfaceMapping) {
          boolean owned = MetaDataUtils.isOwnedRelation(mmd, getStoreManager());
          RelationType relationType = mmd.getRelationType(ec.getClassLoaderResolver());
          if (owned) {
            // Owned relation
            boolean owner = false;
            if (relationType == RelationType.ONE_TO_ONE_UNI || relationType == RelationType.ONE_TO_MANY_UNI ||
                relationType == RelationType.ONE_TO_MANY_BI) {
              owner = true;
            } else if (relationType == RelationType.ONE_TO_ONE_BI && mmd.getMappedBy() == null) {
              owner = true;
            }

            if (!table.isParentKeyProvider(mmd)) {
              // Make sure the parent key is set properly between parent and child objects
              if (!owner) {
                ObjectProvider parentOP = ec.findObjectProvider(relInfo.value);
                EntityUtils.checkParentage(op.getObject(), parentOP);
              } else {
                EntityUtils.checkParentage(relInfo.value, op);
              }
              mapping.setObject(ec, datastoreEntity, IS_FK_VALUE_ARR, relInfo.value, op, mmd.getAbsoluteFieldNumber());
            }
          } else {
            // Unowned relation
            mapping.setObject(ec, datastoreEntity, IS_FK_VALUE_ARR, relInfo.value, op, mmd.getAbsoluteFieldNumber());
          }
        }
      } catch (NotYetFlushedException e) {
        // Ignore this. We always have the object in the datastore, at least partially to get the key
      }
    }

    // Stage 2 : postInsert/postUpdate
    for (RelationStoreInformation relInfo : relationStoreInfos) {
      try {
        JavaTypeMapping mapping = table.getMemberMappingInDatastoreClass(relInfo.mmd);
        if (mapping instanceof ArrayMapping || mapping instanceof MapMapping) {
          // Ignore postInsert/update for arrays/maps since don't support backing stores
        } else if (mapping instanceof MappingCallbacks) {
          if (insert) {
            ((MappingCallbacks)mapping).postInsert(op);
          } else {
            ((MappingCallbacks)mapping).postUpdate(op);
          }
        }
      } catch (NotYetFlushedException e) {
        // Ignore this. We always have the object in the datastore, at least partially to get the key
      }
    }

    // Stage 3 : set child keys in parent
    for (RelationStoreInformation relInfo : relationStoreInfos) {
      AbstractMemberMetaData mmd = relInfo.mmd;
      RelationType relationType = mmd.getRelationType(ec.getClassLoaderResolver());

      boolean owned = MetaDataUtils.isOwnedRelation(mmd, getStoreManager());
      if (owned) {
        // Owned relations only store child keys if storageVersion high enough, and at "owner" side.
        if (!getStoreManager().storageVersionAtLeast(StorageVersion.WRITE_OWNED_CHILD_KEYS_TO_PARENTS)) {
View Full Code Here

        // We only support many-to-many for unowned relations
        throw new InvalidMetaDataException(GAE_LOCALISER, "AppEngine.MetaData.ManyToManyRelationNotSupported",
            ammd.getFullFieldName());
      }

      RelationType relType = ammd.getRelationType(clr);
      if (ammd.getEmbeddedMetaData() == null &&
          (relType == RelationType.ONE_TO_ONE_UNI || relType == RelationType.ONE_TO_ONE_BI ||
           relType == RelationType.ONE_TO_MANY_UNI || relType == RelationType.ONE_TO_MANY_BI) &&
          !getBooleanConfigProperty(ALLOW_MULTIPLE_RELATIONS_OF_SAME_TYPE) &&
          !storeMgr.storageVersionAtLeast(StorageVersion.READ_OWNED_CHILD_KEYS_FROM_PARENTS)) {
View Full Code Here

    }

    // Figure out if this field is the owning side of a one to one or a one to
    // many.  If it is, look at the mapping of the child class and make sure their
    // pk isn't Long or unencoded String.
    RelationType relationType = ammd.getRelationType(clr);
    if (relationType == RelationType.NONE || ammd.isEmbedded()) {
      return;
    }
    AbstractClassMetaData childAcmd = null;
    if (relationType == RelationType.ONE_TO_MANY_BI || relationType == RelationType.ONE_TO_MANY_UNI) {
View Full Code Here

    ClassLoaderResolver clr = op.getExecutionContext().getClassLoaderResolver();
    DatastoreManager storeMgr = (DatastoreManager)op.getExecutionContext().getStoreManager();
    for (MappingCallbacks callback : callbacks) {
      JavaTypeMapping mapping = (JavaTypeMapping) callback;
      AbstractMemberMetaData mmd = mapping.getMemberMetaData();
      RelationType relationType = mmd.getRelationType(clr);
      if (callback instanceof ArrayMapping) {
        // Handle dependent field delete
        if (RelationType.isRelationMultiValued(relationType)) {
          // Field of type PC[], make sure it is loaded and handle dependent-element
          ExecutionContext ec = op.getExecutionContext();
View Full Code Here

TOP

Related Classes of org.datanucleus.metadata.RelationType

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.