Hi Isomorphic,
please see this v10.1p_2016-01-19 BuiltInDS-based testcase:
supplyItem.ds.xml addition:
BuiltInDS.java:
If you click the 2nd button it will use the canSyncCache="false"-operationBinding.
This is returned in the Developer Console's RPC Tab:
More important, the SQL
or in Oracle "SELECT sequencename.CURRVAL FROM dual" is not executed.
In my application, in some places I'm only interested in the PK (eg when creating a log-entry), but not the cacheSync-data. Currently I have to leave canCacheSync enabled in order to get the generated PK.
For me, right now this is only server-side where I have those requests, so this would mean no changed facing the behavior towards the client. I'd just like to be able to get the generated PK on the server.
As the cacheSync request is most likely indexed and therefore not expensive, this is a very minor enhancement.
Best regards
Blama
please see this v10.1p_2016-01-19 BuiltInDS-based testcase:
supplyItem.ds.xml addition:
Code:
<operationBindings> <operationBinding operationType="add" operationId="addNoCacheSync" canSyncCache="false" /> </operationBindings>[B][/B]
BuiltInDS.java:
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.PageKeyHandler; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS implements EntryPoint { private VLayout mainLayout; private IButton recreateBtn; public void onModuleLoad() { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new PageKeyHandler() { public void execute(String keyName) { SC.showConsole(); } }); mainLayout = new VLayout(20); mainLayout.setWidth100(); mainLayout.setHeight100(); recreateBtn = new IButton("Recreate"); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(); } }); mainLayout.addMember(recreateBtn); recreate(); mainLayout.draw(); } private void recreate() { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle("Enhancement: canCacheSync=false should return added PK."); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); final DataSource ds = DataSource.get("supplyItem"); { IButton btn = new IButton("Add normal"); btn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Record r = new Record(); r.setAttribute("itemName", "New with CacheSync"); r.setAttribute("SKU", "1"); r.setAttribute("category", "cat1"); r.setAttribute("unitCost", 1); ds.addData(r); } }); btn.setWidth(250); w.addItem(btn); } { IButton btn = new IButton("Add noCacheSync"); btn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Record r = new Record(); r.setAttribute("itemName", "New without CacheSync"); r.setAttribute("SKU", "2"); r.setAttribute("category", "cat2"); r.setAttribute("unitCost", 2); ds.addData(r, null, new DSRequest() { { setOperationId("addNoCacheSync"); } }); } }); btn.setWidth(250); w.addItem(btn); } w.show(); } }[B][/B]
If you click the 2nd button it will use the canSyncCache="false"-operationBinding.
This is returned in the Developer Console's RPC Tab:
Code:
{ affectedRows:1, invalidateCache:true, isDSResponse:true, operationType:"add", queueStatus:0, status:0, data:null }
Code:
=== 2016-01-19 17:33:28,067 [1-32] INFO SQLDriver - [builtinApplication.supplyItem_add] Executing SQL query on 'HSQLDB' using connection '932072306': CALL IDENTITY()
In my application, in some places I'm only interested in the PK (eg when creating a log-entry), but not the cacheSync-data. Currently I have to leave canCacheSync enabled in order to get the generated PK.
For me, right now this is only server-side where I have those requests, so this would mean no changed facing the behavior towards the client. I'd just like to be able to get the generated PK on the server.
As the cacheSync request is most likely indexed and therefore not expensive, this is a very minor enhancement.
Best regards
Blama
Comment