Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Microsoft Dynamics EntityDefinitions/RelationshipDefinitions #158

Open
blxbrgld opened this issue Jun 23, 2021 · 5 comments
Open
Labels
question Further information is requested

Comments

@blxbrgld
Copy link

Hello,

i'm trying to generate Java classes from a metadata xml following the logic of the odata-client-microsoft-dynamics client but the process fails with the following error:

manyToManyRelationships() in microsoft.dynamics.crm.entity.set.EntityDefinitions cannot override manyToManyRelationships() in microsoft.dynamics.crm.entity.collection.request.EntityMetadataCollectionRequest

The XML definitions for RelationshipDefinitions and EntityDefinitions in my metadata file are similar with those of https://github.com/davidmoten/odata-client/blob/master/odata-client-microsoft-dynamics/src/main/odata/microsoft-dynamics-crm4-v9.1-metadata.xml:

<EntitySet Name="RelationshipDefinitions" EntityType="Microsoft.Dynamics.CRM.RelationshipMetadataBase" />

<EntitySet Name="EntityDefinitions" EntityType="Microsoft.Dynamics.CRM.EntityMetadata">
  <NavigationPropertyBinding Path="Microsoft.Dynamics.CRM.BooleanAttributeMetadata/GlobalOptionSet" Target="GlobalOptionSetDefinitions" />
  <NavigationPropertyBinding Path="ManyToManyRelationships" Target="RelationshipDefinitions" />
  <NavigationPropertyBinding Path="ManyToOneRelationships" Target="RelationshipDefinitions" />
  <NavigationPropertyBinding Path="OneToManyRelationships" Target="RelationshipDefinitions" />
  <NavigationPropertyBinding Path="Microsoft.Dynamics.CRM.EnumAttributeMetadata/GlobalOptionSet" Target="GlobalOptionSetDefinitions" />
</EntitySet>

but the code generated (e.g. for manyToManyRelationships()) is:

public final class EntityDefinitions extends EntityMetadataCollectionRequest {

    public RelationshipDefinitions manyToManyRelationships() {
        return new RelationshipDefinitions(contextPath.addSegment("ManyToManyRelationships"));
    }	
}

public class EntityMetadataCollectionRequest extends CollectionPageEntityRequest<EntityMetadata, EntityMetadataRequest> {
    
	public ManyToManyRelationshipMetadataCollectionRequest manyToManyRelationships() {
        return new ManyToManyRelationshipMetadataCollectionRequest(contextPath.addSegment("ManyToManyRelationships"), Optional.empty());
    }
}

Am i doing something wrong? If i comment out the EntityDefinitions entity set, the process completes successfully. Can this be considered a solution to my problem or it will result a non functional client? What is the purpose of the EntityDefinitions entity set?

Thank you.

@davidmoten
Copy link
Owner

Sorry, I missed this question. I'll have a look.

@davidmoten davidmoten added the question Further information is requested label Jul 12, 2021
@davidmoten
Copy link
Owner

You asked whether the client would be non-functional if you commented out that EntitySet. Should be fine as long as you don't need to make those exact traversals.

@NCarrellOmni
Copy link

NCarrellOmni commented Jun 19, 2024

My team has recently encountered the same issue generating classes from our Dynamics CRM 9 metadata. We commented out these entity definitions and were able to use the generated sources.
We were curious as well, what is the purpose of the EntityDefinitions entity set?

@davidmoten
Copy link
Owner

davidmoten commented Jun 19, 2024

what is the purpose of the EntityDefinitions entity set?

Couldn't tell you more that what you can see in the xml file and perhaps on Microsoft docs. If you don't need to access that information you don't have a problem.

In terms of why we are getting a problem, we can see that EntityDefinitions extends EntityMetadata. EntityMetadata already has the NavigationProperties below in my copy of the xml (which generates fine). I see my copy of the metadata has 2 suffixes on the names which would prevent the name clash (but I don't know if that was a bandaid by me or not). What does this section for EntityMetadata look like for you?

        <NavigationProperty Name="Attributes" Type="Collection(mscrm.AttributeMetadata)" ContainsTarget="true"/>
        <NavigationProperty Name="ManyToManyRelationships2" Type="Collection(mscrm.ManyToManyRelationshipMetadata)"/>
        <NavigationProperty Name="ManyToOneRelationships2" Type="Collection(mscrm.OneToManyRelationshipMetadata)"/>
        <NavigationProperty Name="OneToManyRelationships2" Type="Collection(mscrm.OneToManyRelationshipMetadata)"/>
        <NavigationProperty Name="Keys" Type="Collection(mscrm.EntityKeyMetadata)" ContainsTarget="true"/>

@NCarrellOmni
Copy link

NCarrellOmni commented Jun 20, 2024

We won't need to query the entity metadata so commenting this section out works fine for us.

As for your question, it looks like we've got something similar on our end under EntityMetadata, however they don't have '2' suffixed to the relationship names.

    <NavigationProperty Name="Attributes" Type="Collection(mscrm.AttributeMetadata)"
        ContainsTarget="true" />
    <NavigationProperty Name="ManyToManyRelationships"
        Type="Collection(mscrm.ManyToManyRelationshipMetadata)" />
    <NavigationProperty Name="ManyToOneRelationships"
        Type="Collection(mscrm.OneToManyRelationshipMetadata)" />
    <NavigationProperty Name="OneToManyRelationships"
        Type="Collection(mscrm.OneToManyRelationshipMetadata)" />
    <NavigationProperty Name="Keys" Type="Collection(mscrm.EntityKeyMetadata)"
        ContainsTarget="true" />

Our EntityDefinitions XML is also similar to https://github.com/davidmoten/odata-client/blob/master/odata-client-microsoft-dynamics/src/main/odata/microsoft-dynamics-crm4-v9.1-metadata.xml

<EntitySet Name="EntityDefinitions"
        EntityType="Microsoft.Dynamics.CRM.EntityMetadata">
    <NavigationPropertyBinding
        Path="Microsoft.Dynamics.CRM.BooleanAttributeMetadata/GlobalOptionSet"
        Target="GlobalOptionSetDefinitions" />
    <NavigationPropertyBinding Path="ManyToManyRelationships"
        Target="RelationshipDefinitions" />
    <NavigationPropertyBinding Path="ManyToOneRelationships"
        Target="RelationshipDefinitions" />
    <NavigationPropertyBinding Path="OneToManyRelationships"
        Target="RelationshipDefinitions" />
    <NavigationPropertyBinding
        Path="Microsoft.Dynamics.CRM.EnumAttributeMetadata/GlobalOptionSet"
        Target="GlobalOptionSetDefinitions" />
</EntitySet>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants