Dear Isomorphic Support Team,
I am trying to update an SQL entry to a simple table using a DSRequest, but I come up with the following error
"Insert,update or replace operation requires non-empty values;check submitted values parameter"
Here is the code that I am trying to execute
This is the DS.XML File
When I run the code, I get the non-empty value and the following output log
The only work around I have found is to change the criteria and the values in HashMap, but that would require creating lots of unnecessary final variables to be able to make it work
These are the links
http://forums.smartclient.com/showthread.php?t=21606
http://forums.smartclient.com/showthread.php?t=15395
and this is the working code
But I have multiple similar update and remove statements running in a for loop and if I have to create final variables for all, it would be a mess.
So please Support Team, can you provide me with a simple working example of an update query using the otherwise awesome methods setFieldValue and setCriteriaValue
Thank you for your reply
I am trying to update an SQL entry to a simple table using a DSRequest, but I come up with the following error
"Insert,update or replace operation requires non-empty values;check submitted values parameter"
Here is the code that I am trying to execute
Code:
int totalPrice = 450; //This is just for testing purposes. In Reality its calculated
DSRequest finTraReq = new DSRequest("transaction","update");
finTraReq.setCriteriaValue("id", 88);
finTraReq.setFieldValue("totalPrice", totalPrice);
finTraRes.execute();
Code:
<DataSource ID="transaction" serverType="sql" tableName="transaction">
<fields>
<field name="id" title="id" primaryKey="true" type="sequence" hidden="true"/>
<field name="totalPrice" type="integer"/>
<field name="description" type="text" />
<field name="contactId" type="integer" foreignKey="contacts.contactId"/>
</fields>
</DataSource>
Code:
--------------------------------------------> EXECUTING UPDATE TRANSACTION REQUEST
--------------------------------------------> TRANSACTION UPDATE CRITERIA ID: null
--------------------------------------------> TRANSACTION UPDATE TOTAL PRICE ID: 450
=== 2012-04-11 13:13:04,855 [l0-4] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
=== 2012-04-11 13:13:04,855 [l0-4] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
=== 2012-04-11 13:13:04,855 [l0-4] INFO SQLDataSource - [builtinApplication.null] Performing update operation with
criteria: {id:87} values: 0 valueSets
=== 2012-04-11 13:13:04,856 [l0-4] WARN SQLDataSource - [builtinApplication.null] Insert, update or replace operation requires non-empty values; check submitted values parameter
=== 2012-04-11 13:13:04,856 [l0-4] DEBUG DataSourceDMI - Invocation threw exception
java.lang.Exception: Insert, update or replace operation requires non-empty values; check submitted values parameter
at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1236)
at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:293)
at com.isomorphic.sql.SQLDataSource.executeUpdate(SQLDataSource.java:241)
at com.isomorphic.datasource.DataSource.execute(DataSource.java:1295)
at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
at com.isomorphic.application.AppBase.execute(AppBase.java:491)
at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1948)
at com.smartgwt.sample.server.ExportDMI.processCart(ExportDMI.java:224)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:950)
at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:386)
at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1945)
at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199)
at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
=== 2012-04-11 13:13:04,857 [l0-4] WARN RequestContext - dsRequest.execute() failed:
java.lang.Exception: Insert, update or replace operation requires non-empty values; check submitted values parameter
at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1236)
at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:293)
at com.isomorphic.sql.SQLDataSource.executeUpdate(SQLDataSource.java:241)
at com.isomorphic.datasource.DataSource.execute(DataSource.java:1295)
at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
at com.isomorphic.application.AppBase.execute(AppBase.java:491)
at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1948)
at com.smartgwt.sample.server.ExportDMI.processCart(ExportDMI.java:224)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:950)
at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:386)
at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1945)
at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199)
at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
=== 2012-04-11 13:13:04,858 [l0-4] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
=== 2012-04-11 13:13:04,858 [l0-4] DEBUG SQLTransaction - Rolling back test transaction "1249457275"
=== 2012-04-11 13:13:04,859 [l0-4] WARN DataStructCache - File cartItem.ds not found at explicitly specified location /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/system/reference/inlineExamples/serverExamples/sql/userSpecificData, checking project-wide area
=== 2012-04-11 13:13:04,860 [l0-4] DEBUG RPCManager - non-DMI response, dropExtraFields: false
=== 2012-04-11 13:13:04,860 [l0-4] DEBUG SQLTransaction - Ending test transaction "1249457275"
=== 2012-04-11 13:13:04,861 [l0-4] INFO Compression - /builtinds/sc/IDACall: 216 -> 175 bytes
=== 2012-04-11 13:13:05,117 [l0-4] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Dialog/warn.png
=== 2012-04-11 13:13:05,120 [l0-4] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/headerIcons/close.png
=== 2012-04-11 13:13:05,120 [l0-6] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_TL.png
=== 2012-04-11 13:13:05,121 [l0-5] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_T.png
=== 2012-04-11 13:13:05,122 [l0-2] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_R.png
=== 2012-04-11 13:13:05,123 [l0-6] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_BL.png
=== 2012-04-11 13:13:05,123 [l0-0] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_TR.png
=== 2012-04-11 13:13:05,124 [l0-3] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_L.png
=== 2012-04-11 13:13:05,125 [l0-4] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_B.png
=== 2012-04-11 13:13:05,125 [l0-0] INFO Download - Returning 304: Not modified on conditional get of: /Users/kalinkirev/Documents/workspace/builtinds/war/builtinds/sc/skins/Enterprise/images/Window/window_BR.png
These are the links
http://forums.smartclient.com/showthread.php?t=21606
http://forums.smartclient.com/showthread.php?t=15395
and this is the working code
Code:
final Integer id = new Integer(87);
final Integer totPrice = new Integer(450);
DSRequest finTraReq = new DSRequest("transaction","update");
finTraReq.setCriteria(new HashMap() {{ put("id", id); }});
finTraReq.setValidatedValues(new HashMap() {{ put("totalPrice", totPrice); }});
finTraReq.execute();
So please Support Team, can you provide me with a simple working example of an update query using the otherwise awesome methods setFieldValue and setCriteriaValue
Thank you for your reply
Comment