OData V2 vs V4 — 성능 차이 #shorts #SAP #UI5

Moderator · 조회 3

이 글이 답하는 질문

  • UI5에서 V2 모델과 V4 모델, 코드가 얼마나 다른가?
  • V2 앱을 V4로 바꿀 때 뭐가 달라지나?
  • 언제 V4로 넘어가야 하나?

핵심 차이 한눈에

V2V4
모델 클래스odata.v2.ODataModelodata.v4.ODataModel
CRUDmodel.create() / remove()ODataContextBinding.invoke()
배치 전송자동 그루핑submitBatch(groupId) 명시
결과 처리success/error 콜백Promise 기반
Fiori ElementsV2 FlexibleColumnLayoutV4 필수 (FE v2+)

직접 해보기

1. V2 — 엔티티 생성

var oModel = this.getView().getModel(); // v2.ODataModel
oModel.create("/SalesOrderSet", {
  CustomerName: "ACME",
  NetAmount: "500.00"
}, {
  success: function(oData) { /* 완료 */ },
  error:   function(oErr)  { /* 에러 */ }
});

2. V4 — 동일 작업

var oListBinding = oModel.bindList("/SalesOrderSet");
var oContext = oListBinding.create({
  CustomerName: "ACME",
  NetAmount: "500.00"
});
// refresh 없이 바로 UI 반영
oContext.created().then(function() { /* 완료 */ });

3. V4 전환 체크리스트

  • import 경로 v2 → v4 변경
  • submitChanges()submitBatch(groupId)
  • attachRequestCompleted → Promise / dataReceived
  • Function Import → OData Action으로 교체
  • setProperty() V4에서 직접 지원 — updateEntry 불필요

삽질 노트

  • V4에는 model.read()가 없다 — bindContext() 또는 bindList()로 대체
  • deferred 배치 그룹은 V4에서 submitBatch()만으로 전송 — 자동 플러시 없음
  • V2 annotation을 V4 모델에 그대로 쓰면 충돌 — $Annotations 구조 재점검 필수

핵심 한 줄

V4는 Promise + 명시적 배치 — 코드가 길어져도 제어권은 확실히 올라간다.

더 파볼 주제

  • OData V4 submitBatch vs immediate 그룹 차이
  • Fiori Elements V4 마이그레이션 체크리스트 (SAP BTP cockpit)