在olingo中扩展元数据时获取JPA文件名

Get the JPA filed name when we extended the metadata in olingo

Here 我们已经解释了如何在 olingo V2 中扩展 metadata oData 服务。

<JPAEntityType name="SalesOrderHeader">
   <EDMEntityType>SalesOrder</EDMEntityType> 
   <EDMEntitySet>SalesOrders</EDMEntitySet> 
   <JPAAttributes>
       <JPAAttribute name="soId">ID</JPAAttribute> 
       <JPAAttribute name="netAmount">NetAmount</JPAAttribute> 
       <JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute> 
   </JPAAttributes>
   <JPARelationships>
       <JPARelationship name="salesOrderItem">SalesOrderLineItemDetails</JPARelationship> 
       <JPARelationship name="notes">NotesDetails</JPARelationship> 
    </JPARelationships>
</JPAEntityType>

这一小段代码解释了如何将 JPA 实体字段的名称 buyerAddress 更改为新名称 BuyerAddressInfo

现在的问题是,当我可以访问BuyerAddressInfoODataJPAContext时,如何访问原始名称?

我从 here 中发现了以下方法。通过这种方法,我可以通过 buyerAddress 和 JPA 实体名称来访问 BuyerAddressInfo

import org.apache.olingo.odata2.jpa.processor.api.access.JPAEdmMappingModelAccess;
import org.apache.olingo.odata2.jpa.processor.api.factory.ODataJPAFactory;
// .....
JPAEdmMappingModelAccess jpaEdmMappingModelAccess = 
ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmMappingModelAccess(oDataJPAContext);
jpaEdmMappingModelAccess.loadMappingModel();
String newName = jpaEdmMappingModelAccess.mapJPAAttribute("SalesOrderHeader", "SalesOrderHeader"));

然而我要找的恰恰相反!因此,目前我使用 Map 并收集所有对,每次我迭代它们!