仅拥有一个OData数据源会更好吗? [英] Is it better to have just one OData dataSource?

查看:125
本文介绍了仅拥有一个OData数据源会更好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的控制器通常调用一个dataSource都没有问题.

My app's controllers mostly call one dataSource with no issues.

其中之一,但是使用三个单独的数据源,访问它们时有时会返回403禁止的错误.

One of them, however uses three seperate datasources, and sometime returns 403 Forbidden errors when accessing them.

"dataSources": {
  "ZSV_SURVEY_SRV": {
    "uri": "/SAPUI5-ABAP-SFI/sap/opu/odata/sap/ZSV_SURVEY_SR/",
    "type": "OData",
    "settings": {
      "odataVersion": "2.0",
      "localUri": "localService/metadata.xml"
    }
  },
  "ZRUI_COMMON_SRV": {
    "uri": "/SAPUI5-ABAP-SFI/sap/opu/odata/sap/ZRUI_COMMON_SRV/",
    "type": "OData",
    "settings": {
      "odataVersion": "2.0",
      "localUri": "localService/ZRUI_COMMON_SRV/metadata.xml"
    }
  },
  "ZTC_SHOP_TRADING_CALENDAR_SRV": {
    "uri": "/SAPUI5-ABAP-SFI/sap/opu/odata/sap/ZTC_SHOP_TRADING_CALENDAR_SRV/",
    "type": "OData",
    "settings": {
      "odataVersion": "2.0",
      "localUri": "localService/ZTC_SHOP_TRADING_CALENDAR_SRV/metadata.xml"
    }
  }
}

将所有方法都合并到一个数据源中会更好(例如ZSV_SURVEY_SRV?还是三个单独的数据源应该没有问题?

Would it be better to incorporate the methods all into one dataSource (e.g. ZSV_SURVEY_SRV? Or should three separate dataSources be fine and present no problems?

如果三个dataSources都很好,为什么我有时会出现403错误?

If three dataSources are fine, why do I sometime get the 403 error?

这两种方式都有性能优势吗?

Is there a performance advantage either way?

推荐答案

除了您面临的403 Forbidden错误之外,将所有内容都放在同一服务中具有其优势:

Apart from the 403 Forbidden error you are facing, having everything in the same service has its advantages:

设计视角

  1. OData在同一服务中支持多个数据源 (实体集)
  2. 您可以轻松实现导航属性 您的实体之间
  3. 您将只需要一个ODataModel实例 在您的UI5应用中
  4. 无需执行承诺或任何其他内容 确保加载所有服务的其他机制 成功
  5. 无需在其中使用复杂的绑定 UI5从两个不同的模型中获取数据
  6. 很容易想象 一个特定的属性应该存在于一个以上的OData中 服务.也可能会相信您可能也有 由于它们之间的不一致(长度,精度, 比例,注释等)
  1. OData supports multiple data sources inside the same service (entity sets)
  2. You can easily implement navigation properties between your entities
  3. You will need just one ODataModel instance inside your UI5 app
  4. There is no need to implement Promises or any other mechanism to make sure that all services are loaded successfully
  5. There would be no need to use complex bindings in UI5 taking data from two different models
  6. It's easy to imagine that a particular property should is present in more that one OData services. It's also possible to believe that you might also have errors due to inconsistencies between them (length, precision, scale, annotations, etc)

性能方面的观点

  1. 由于只有一个元数据,因此只有一个往返行程才能获取它
  2. 为所有服务缓存元数据的更改较小

绝对有更多的理由只使用一项服务.通常,Fiori应用程序仅在服务中使用.此外,此服务仅由提及的Fiori应用程序使用.这使维护方式更容易.

There are definitely more reason for using just one service. As a general rule a Fiori app uses only on service. Also, this service is only used by the Fiori app mentioned. This makes maintenance way easier.

当然有例外,特别是在注释服务方面.

Of course there are exceptions for that, specially when it comes to annotation services.

如果您确实有充分的理由需要三种不同的服务,请考虑同时结合所有三种来创建第4种服务.在SEGW中,您可以通过右键单击Data Model文件夹并使用 Include >> OData Service(GW)选项

If you really need three different services for a good reason consider as well creating a 4th one combining all three. In SEGW you can combine other services inside a project by right-clicking in Data Model folder and using Include >> OData Service (GW) option

但无论如何,请在同一服务中使用不同的实体集.值得.

But in any case make use of different entity sets in the same service. It's worth it.

这篇关于仅拥有一个OData数据源会更好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆