Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/Dynamic/RefactorPhaseIForSparseMerge"

(DynamicEntity Refactor (Phase I))
Line 43: Line 43:
  
 
=== <code>DynamicEntity</code> Refactor (Phase I) ===
 
=== <code>DynamicEntity</code> Refactor (Phase I) ===
The <code>DynamicEntity</code> interface allows one to tell the difference between 'the value was never set' and 'the value is currently <code>null</code>' using <code>public boolean isSet(String propertyName)</code>
+
The <code>DynamicEntity</code> interface allows one to tell the difference between 'the value was never set' and 'the value is currently <code>null</code>' using the <code>boolean isSet(String propertyName)</code> API on <code>DynamicEntity</code>
 +
 
 +
Please refer to the page [[EclipseLink/Development/Dynamic#Refactoring_.28Phase_I.29]]

Revision as of 14:52, 18 March 2010


Sparse Merge

Current status

The current DBWS implementation (as of 10/02/18) does not handle SOAP update messages that contain changed-only information. The Update operation (part of CRUD lifecycle) requires 'theInstance' to be fully specified in the SOAPMessage; it would be useful to support an update where - excluding PK fields - only the changed elements are specified

For example, Employee 1111 is assigned a new job 'Dog walker':

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Header/>
  <env:Body>
    <srvc:update_empType xmlns:srvc="urn:empService" xmlns:ns1="urn:emp">    
      <srvc:theInstance>
        <ns1:empType>
          <ns1:empno>1111</ns1:empno>   <- primary key
          <ns1:job>Dog walker</ns1:job> <- updated job title
        </ns1:empType>    
      </srvc:theInstance>
    </srvc:update_empType>
  </env:Body>
</env:Envelope>

If this representation of Employee 1111 were to be marshalled into an object, most fields (ename, mgr, etc.) will contain null. Any attempt to merge this with a version retrieved from the database would *over-write* committed data with nulls. Because of this, the complete instance must be specified:

<srvc:theInstance>
  <ns1:empType>
    <ns1:empno>1111</ns1:empno>   <- primary key
    <ns1:ename>NORMAN</ns1:ename>
    <ns1:job>Dog walker</ns1:job>   <- only field that changed
    <ns1:mgr>7698</ns1:mgr>
    <ns1:hiredate>1998-09-08T00:00:00.0</ns1:hiredate>
    <ns1:sal>10</ns1:sal>
    <ns1:comm>0.1</ns1:comm>
    <ns1:deptno xsi:nil="true"/>
  </ns1:empType>    
</srvc:theInstance>

Note the use of xsi:nil to indicate null for our Dog walker's department.

DynamicEntity Refactor (Phase I)

The DynamicEntity interface allows one to tell the difference between 'the value was never set' and 'the value is currently null' using the boolean isSet(String propertyName) API on DynamicEntity

Please refer to the page EclipseLink/Development/Dynamic#Refactoring_.28Phase_I.29

Back to the top