DataSource
<DataSource ID="cocSQL"
serverType="sql"
tableName="coc"/>
<fields>
<field name="coc_id" type="sequence" hidden="true" primaryKey="true"/>
<field name="change_vendor_material_id" type="integer" foreignKey="vmSQL.vendor_material_id"
joinType="outer"/>
<field name="vendor_id" type="integer" includeFrom="vmSQL.vendor_id"
includeVia="change_vendor_material_id" joinType="outer"/>
<field name="comment" type="text" length="250"/>
</fields>
<operationBinding operationType="update" operationId="multiUpdate" allowMultiUpdate="true" serverMethod="multiUpdate">
<serverObject lookupStyle="spring" bean="cocSQLService"/>
</operationBinding>
</DataSource>
cocSQLServiceImpl:-
public DSResponse multiUpdate(final DSRequest dsRequest, final RPCManager rpcManager) throws Exception {
final DSRequest bulkUpdate = new DSRequest("cocSQL", DataSource.OP_UPDATE, rpcManager);
final Map<String, Object> values = dsRequest.getClientSuppliedValues();
final AdvancedCriteria advancedCriteria = AdvancedCriteria.decodeClientCriteria((String) values.get("CRITERIA"));
bulkUpdate.addToCriteria(advancedCriteria);
final Map<String, Object> newValues = new HashMap();
newValues.put("comment",values.get("comment"))
bulkUpdate.setAllowMultiUpdate(true);
bulkUpdate.setValues(newValues);
final DSResponse result = bulkUpdate.execute();
return result;
}
Client.java
AdvancedCriteria filterCriteria = new AdvancedCriteria(OperatorId.AND,
new Criterion[] { new Criterion(vendor_id, OperatorId.IN_SET, {-55});
final Map<String, Object> reqData = new HashMap<>();
final DSRequest request = new DSRequest();
reqData .put("comment", "update the comment");
reqData.put("CRITERIA", filterCriteria.toJSON());
request.setData(reqData);
request.setOperationId("multiUpdate");
DataSource.get("coc").updateData(new Record(),null,request);
Announcement
Collapse
No announcement yet.
X
-
Sorry, this isn’t making much sense. If you think there is a framework problem here and not a problem in your application code, try putting together a minimal, ready-to-run test case and we can take a look.
Leave a comment:
-
Yes, we are using includeFrom, but we are not updating joined columns. Although we have set allowMultiUpdate to true for this operationType. We are using the joined columns to fetch primary keys based on criteria.
Leave a comment:
-
Presumably you are using an includeFrom field to get that join. Per docs, includeFrom fields are not updatable, however, you can add a DMI with logic that updates the related table if you want (just create a new DSRequest in Java, on the server).
Leave a comment:
-
Joins are not working on the Joins
Joins are not working on the Update
I have two fields joined together in the data source. While making fetch it works perfectly. But while making the update call the DSReqest is unable to figure out joined columns.
Query formed for fetch
SELECT * FROM coc LEFT OUTER JOIN vendor_material change_vendor_material_id ON coc.change_vendor_material_id = change_vendor_material_id.vendor_material_id WHERE ( (change_vendor_material_id.vendor_id IN ( -55 ) )
But when I make the update Query formed
UPDATE coc SET comment='comment' WHERE (change_vendor_material_id.vendor_id IN ( -55 ) )
I passed the same criteria to both update and the fetch call
Last edited by alchemistt; 26 Jul 2021, 20:48.Tags: None
Leave a comment: