Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Development/Dynamic/RefactorPhaseIForSparseMerge"
Line 1: | Line 1: | ||
− | + | <css> | |
− | The current DBWS implementation (as of 10/02/18) does not handle SOAP update messages that contain changed-only information. | + | .source-java5 {padding:4px;border:1px solid black;} |
+ | .source-xml {padding:4px;border:1px solid black;} | ||
+ | </css> | ||
+ | == 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': | For example, Employee 1111 is assigned a new job 'Dog walker': | ||
− | + | <source lang="xml"> | |
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> | <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> | ||
<env:Header/> | <env:Header/> | ||
Line 16: | Line 23: | ||
</env:Body> | </env:Body> | ||
</env:Envelope> | </env:Envelope> | ||
− | + | </source> | |
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 retrived from the database would *over-write* committed data with nulls. Because of this, the complete _instance_ must be specified: | 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 retrived from the database would *over-write* committed data with nulls. Because of this, the complete _instance_ must be specified: | ||
− | + | <source lang="xml"> | |
<srvc:theInstance> | <srvc:theInstance> | ||
<ns1:empType> | <ns1:empType> | ||
Line 31: | Line 38: | ||
</ns1:empType> | </ns1:empType> | ||
</srvc:theInstance> | </srvc:theInstance> | ||
− | + | </source> | |
Note the use of {{xsi:nil}} to indicate {{null}} for our Dog walker's department. | Note the use of {{xsi:nil}} to indicate {{null}} for our Dog walker's department. | ||
− | + | === <code>isSet</code> and <code>DynamicEntity/code> === | |
One solution to the above problem is to have a way to tell the difference between a field that has not yet been assigned any value vs. {{null}}. | One solution to the above problem is to have a way to tell the difference between a field that has not yet been assigned any value vs. {{null}}. | ||
− | + | <source lang="java5"> | |
import org.eclipse.persistence.exceptions.DynamicException; | import org.eclipse.persistence.exceptions.DynamicException; | ||
Line 43: | Line 50: | ||
public boolean isSet(String propertyName) throws DynamicException; | public boolean isSet(String propertyName) throws DynamicException; | ||
} | } | ||
− | + | </source> | |
It is helpful to note that the above interface is a subset of the {{DynamicEntity}} interface: | It is helpful to note that the above interface is a subset of the {{DynamicEntity}} interface: | ||
− | + | <source lang="java5"> | |
//EclipseLink imports | //EclipseLink imports | ||
import org.eclipse.persistence.exceptions.DynamicException; | import org.eclipse.persistence.exceptions.DynamicException; | ||
Line 57: | Line 64: | ||
public boolean isSet(String propertyName) throws DynamicException; | public boolean isSet(String propertyName) throws DynamicException; | ||
} | } | ||
− | + | </source> | |
− | Thus, support for Sparse Merge will initially be done through | + | Thus, support for Sparse Merge will initially be done through <code>DynamicEntity</code>'s |
− | + | ==== Changes to <code>DynamicEntity</code> ==== | |
− | The current EclipseLink | + | The current EclipseLink <code>DynamicEntity</code> implementation (as of 10/02/18) sets default values for all fields, which defeats the ability of a merge algorithm to support 'sparse-ness'. Setting default values must be moved out of the 'core' Dynamic Persistence framework and relocated to a Dynamic 'helper' class such as DynamicTypeBuilder or JPADynamicTypeBuilder |
Revision as of 14:39, 18 March 2010
Contents
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 (Template:Ename, Template:Mgr, etc.) will contain Template:Null. Any attempt to merge this with a version retrived 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 Template:Xsi:nil to indicate Template:Null for our Dog walker's department.
isSet
and DynamicEntity/code>
One solution to the above problem is to have a way to tell the difference between a field that has not yet been assigned any value vs. Template:Null.
import org.eclipse.persistence.exceptions.DynamicException; public interface IsSetable { public boolean isSet(String propertyName) throws DynamicException; }
It is helpful to note that the above interface is a subset of the Template:DynamicEntity interface:
//EclipseLink imports import org.eclipse.persistence.exceptions.DynamicException; public interface DynamicEntity { public <T> T get(String propertyName) throws DynamicException; public DynamicEntity set(String propertyName, Object value) throws DynamicException; public boolean isSet(String propertyName) throws DynamicException; }
Thus, support for Sparse Merge will initially be done through <code>DynamicEntity's
Changes to DynamicEntity
The current EclipseLink DynamicEntity
implementation (as of 10/02/18) sets default values for all fields, which defeats the ability of a merge algorithm to support 'sparse-ness'. Setting default values must be moved out of the 'core' Dynamic Persistence framework and relocated to a Dynamic 'helper' class such as DynamicTypeBuilder or JPADynamicTypeBuilder