Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    When allowMultiUpdate is true, there is no automatic re-selection of the data, since you are assumed to have possibly affected multiple records. So that's expected.

    As far as the claim of the ignored addCriteria() call, can you provide a test case for that? If it's as straightforward an issue and you think from your application code, it should be easy to reproduce by modifying a sample.

    Comment


      #17
      Hi Isomorphic,

      please see attached sample based on builtInDS, but using Oracle (in order to show the CurrVal-SELECT problem).

      The badDelete has two problems:
      1. Incomplete WHERE clause
      2. CurrVal-SELECT which should not be there (please make sure that the DELETE actually deletes a row/has data to delete, otherwise the CurrVal-SELECT is not present)


      BuiltInDS.java (Load T_SYS_DELETEALLOWEDTENANT in DSLoader, too!):
      Code:
      package com.smartgwt.sample.client;
      
      import com.google.gwt.core.client.EntryPoint;
      import com.smartgwt.client.core.KeyIdentifier;
      import com.smartgwt.client.data.DataSource;
      import com.smartgwt.client.util.PageKeyHandler;
      import com.smartgwt.client.util.Page;
      import com.smartgwt.client.util.SC;
      import com.smartgwt.client.widgets.IButton;
      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 vL;
      	final DataSource ds = DataSource.get("T_SYS_DELETEALLOWEDTENANT");
      
      	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();
      			}
      		});
      
      		vL = new VLayout(5);
      		vL.setPadding(20);
      		vL.setWidth100();
      		vL.setHeight100();
      
      		IButton goodDeleteBtn = new IButton("Good Delete");
      		goodDeleteBtn.setWidth(150);
      		goodDeleteBtn.addClickHandler(new ClickHandler() {
      			@Override
      			public void onClick(ClickEvent event) {
      				ds.performCustomOperation("goodDelete");
      			}
      		});
      
      		IButton badDeleteBtn = new IButton("Bad Delete");
      		badDeleteBtn.setWidth(150);
      		badDeleteBtn.addClickHandler(new ClickHandler() {
      			@Override
      			public void onClick(ClickEvent event) {
      				ds.performCustomOperation("badDelete");
      			}
      		});
      
      		vL.addMembers(goodDeleteBtn, badDeleteBtn);
      		vL.draw();
      	}
      }
      T_SYS_DELETEALLOWEDTENANT.ds.xml:
      Code:
      <DataSource dbName="Oracle" tableName="T_SYS_DELETEALLOWEDTENANT" ID="T_SYS_DELETEALLOWEDTENANT"
      	serverType="sql" serverConstructor="com.smartgwt.sample.server.listener.MySQLDataSource">
      	<fields>
      		<field primaryKey="true" hidden="true" name="ID" type="sequence" />
      		<field hidden="true" name="TENANT_ID" type="integer" canEdit="false" />
      		<field name="TYPE" length="10" type="text" />
      	</fields>
      	<serverObject lookupStyle="new" className="com.smartgwt.sample.server.listener.T_SYS_DELETEALLOWEDTENANT" />
      	<operationBindings>
      		<operationBinding operationType="custom" operationId="goodDelete" serverMethod="goodDelete"></operationBinding>
      		<operationBinding operationType="custom" operationId="badDelete" serverMethod="badDelete"></operationBinding>
      	</operationBindings>
      </DataSource>
      MySQLDataSource.java:
      Code:
      package com.smartgwt.sample.server.listener;
      
      import com.isomorphic.criteria.AdvancedCriteria;
      import com.isomorphic.criteria.Criterion;
      import com.isomorphic.criteria.DefaultOperators;
      import com.isomorphic.criteria.criterion.IsNullCriterion;
      import com.isomorphic.criteria.criterion.SimpleCriterion;
      import com.isomorphic.datasource.DSField;
      import com.isomorphic.datasource.DSRequest;
      import com.isomorphic.datasource.DSResponse;
      import com.isomorphic.datasource.DataSource;
      import com.isomorphic.sql.SQLDataSource;
      
      
      public class MySQLDataSource extends SQLDataSource {
      	private static final long serialVersionUID = 3994104605640773331L;
      
      	/*
      	 * See:
      	 * http://forums.smartclient.com/showthread.php?t=28646
      	 * http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/docs/WriteCustomDataSource.html
      	 * http://www.smartclient.com/smartgwtee/server/javadoc/com/isomorphic/sql/SQLDataSource.html
      	 */
      	@Override
      	public DSResponse executeRemove(DSRequest request) throws Exception {
      		modifyCriteria(request);
      		return super.executeRemove(request);
      	}
      
      	private static DSRequest modifyCriteria(DSRequest request) throws Exception {
      		// Add "TENANT_ID = x" - Criteria for fetch/update/remove
      		if (request.getOperationType().equals(DataSource.OP_FETCH) || request.getOperationType().equals(DataSource.OP_UPDATE)
      				|| request.getOperationType().equals(DataSource.OP_REMOVE)) {
      
      			// TODO: See http://forums.smartclient.com/showthread.php?t=29408 for why the two-param version is used here.
      			// dsRequest.addToCriteria("TENANT_ID", DefaultOperators.Equals,
      			// User.getUserTenantId(dsRequest.getHttpServletRequest()));
      			request.addToCriteria("TENANT_ID", getTenantId(request));
      			// Add additional "xyz_TENANT_ID = x" - Criteria for fetch for
      			// "includeFrom"-fields
      			if (request.getOperationType().equals(DataSource.OP_FETCH)) {
      				for (Object fn : request.getDataSource().getFieldNames()) {
      					String fieldName = fn.toString();
      					if ((request.getConsolidatedOutputs() == null || request.getConsolidatedOutputs().contains(fn))
      							&& fieldName.endsWith("_TENANT_ID")) {
      						if (!isOuterJoined(fieldName, request.getDataSource())) {
      							request.addToCriteria(fieldName, DefaultOperators.Equals, getTenantId(request));
      						} else {
      							AdvancedCriteria ac = new AdvancedCriteria(DefaultOperators.Or, new Criterion[] {
      									new SimpleCriterion(fieldName, DefaultOperators.Equals, getTenantId(request)), new IsNullCriterion(fieldName) });
      							request.addToCriteria(ac);
      						}
      					}
      				}
      			}
      		}
      		return request;
      	}
      
      	private static boolean isOuterJoined(String includingField, DataSource ds) {
      		DSField includingFieldDSField = ds.getField(includingField);
      		String includeFromString = includingFieldDSField.getProperty("includeFrom");
      
      		String includeFromTable = (includeFromString == null || includeFromString.indexOf(".") == -1) ? null : includeFromString.substring(0,
      				includeFromString.indexOf("."));
      
      		if (includeFromTable != null)
      			for (Object fn : ds.getFieldNames()) {
      				String fieldName = fn.toString();
      				DSField dsField = ds.getField(fieldName);
      				if (dsField.getProperty("foreignKey") != null && dsField.getProperty("foreignKey").startsWith(includeFromTable + "."))
      					return "outer".equals(dsField.getProperty("joinType"));
      			}
      		return false;
      	}
      
      	private static long getTenantId(DSRequest request) {
      		return 12L;
      	}
      }
      T_SYS_DELETEALLOWEDTENANT.java (serverside DMI with the buggy request):
      Code:
      package com.smartgwt.sample.server.listener;
      
      import javax.servlet.http.HttpServletRequest;
      
      import com.isomorphic.criteria.DefaultOperators;
      import com.isomorphic.criteria.criterion.SimpleCriterion;
      import com.isomorphic.datasource.DSRequest;
      import com.isomorphic.datasource.DSResponse;
      import com.isomorphic.datasource.DataSource;
      
      public class T_SYS_DELETEALLOWEDTENANT {
      
      	public DSResponse goodDelete(DSRequest dsRequest, HttpServletRequest servletRequest) throws Exception {
      		DSRequest removeFromDeleteAllowedTenantRequest = new DSRequest("T_SYS_DELETEALLOWEDTENANT", DataSource.OP_REMOVE,
      				dsRequest.getRPCManager());
      		removeFromDeleteAllowedTenantRequest.addToCriteria(new SimpleCriterion("TYPE", DefaultOperators.Equals, "DELETE"));
      		removeFromDeleteAllowedTenantRequest.setAllowMultiUpdate(true);
      		return removeFromDeleteAllowedTenantRequest.execute();
      	}
      
      	public DSResponse badDelete(DSRequest dsRequest, HttpServletRequest servletRequest) throws Exception {
      		DSRequest removeFromDeleteAllowedTenantRequest = new DSRequest("T_SYS_DELETEALLOWEDTENANT", DataSource.OP_REMOVE,
      				dsRequest.getRPCManager());
      		removeFromDeleteAllowedTenantRequest.addToCriteria(new SimpleCriterion("TYPE", DefaultOperators.Equals, "DELETE"));
      		// removeFromDeleteAllowedTenantRequest.setAllowMultiUpdate(true);
      		return removeFromDeleteAllowedTenantRequest.execute();
      	}
      }
      DDL Statements:
      Code:
      DROP SEQUENCE t_sys_deleteallowedtenant_id ;
      CREATE TABLE t_sys_deleteallowedtenant
        (
          id        INTEGER CONSTRAINT NNC_sys_delallowed_id NOT NULL ,
          tenant_id INTEGER CONSTRAINT NNC_sys_delallowed_tenant_id NOT NULL ,
          type      VARCHAR2 (10 CHAR) CONSTRAINT NNC_sys_delallowed_type NOT NULL
        )
        LOGGING ;
      ALTER TABLE t_sys_deleteallowedtenant ADD CONSTRAINT CK_sys_deleteallowedtenant_ty CHECK ( type IN ('UPDATE', 'DELETE')) ;
      CREATE UNIQUE INDEX PK_sys_deleteallowedtenant ON t_sys_deleteallowedtenant
        (
          tenant_id ASC , id ASC
        )
        LOGGING COMPRESS 1 ;
      CREATE UNIQUE INDEX UX_sys_deleteallowedtenant_ty ON t_sys_deleteallowedtenant
        (
          tenant_id ASC , type ASC
        )
        LOGGING COMPRESS 1 ;
        ALTER TABLE t_sys_deleteallowedtenant ADD CONSTRAINT PK_sys_deleteallowedtenant PRIMARY KEY ( tenant_id, id ) USING INDEX PK_sys_deleteallowedtenant ;
        ALTER TABLE t_sys_deleteallowedtenant ADD CONSTRAINT UC_sys_deleteallowedtenant_ty UNIQUE ( tenant_id , type ) USING INDEX UX_sys_deleteallowedtenant_ty ;
      CREATE SEQUENCE t_sys_deleteallowedtenant_ID START WITH 1 NOCACHE ORDER ;
      CREATE OR REPLACE TRIGGER t_sys_deleteallowedtenant_B_I_ BEFORE
        INSERT ON t_sys_deleteallowedtenant FOR EACH ROW WHEN (NEW.id IS NULL) BEGIN :NEW.id := t_sys_deleteallowedtenant_ID.NEXTVAL;
      END;
      /
      (Re)Create row after goodDelete:
      Code:
      INSERT INTO T_SYS_DELETEALLOWEDTENANT (TENANT_ID, TYPE, ID) VALUES (12, 'DELETE', T_SYS_DELETEALLOWEDTENANT_ID.NextVal);
      server.properties addition:
      Code:
      sql.defaultDatabase: Oracle
      sql.useAnsiJoins: true
      
      sql.Oracle.database.type: oracle
      sql.Oracle.autoJoinTransactions: true
      sql.Oracle.database.supportsSQLLimit: false
      
      sql.Oracle.interface.credentialsInURL: true
      sql.Oracle.interface.type: dataSource
      
      sql.Oracle.driver: oracle.jdbc.pool.OracleDataSource
      sql.Oracle.driver.serverName: localhost
      sql.Oracle.driver.portNumber: 1521
      sql.Oracle.driver.databaseName: REPLACE
      sql.Oracle.driver.user: REPLACE
      sql.Oracle.driver.password: REPLACE
      
      sql.Oracle.driver.driverType: thin
      sql.Oracle.driver.networkProtocol: tcp
      sql.Oracle.driver.context:
      badDelete Serverlog:
      Code:
      === 2015-08-20 10:39:26,691 [c-50] INFO  RequestContext - URL: '/BuiltInDS/builtinds/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: host:localhost:8080
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: user-agent:Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: accept-language:de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: accept-encoding:gzip, deflate
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: dnt:1
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: content-type:application/x-www-form-urlencoded; charset=UTF-8
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: referer:http://localhost:8080/BuiltInDS/BuiltInDS.html
      === 2015-08-20 10:39:26,692 [c-50] DEBUG IDACall - Header Name:Value pair: content-length:834
      === 2015-08-20 10:39:26,693 [c-50] DEBUG IDACall - Header Name:Value pair: cookie:JSESSIONID=F6688982F8C2D56B93A30CE0C6BFAFC9; isc_cState=ready; GLog=%7B%0D%20%20%20%20trackRPC%3Atrue%2C%20%0D%20%20%20%20isc_pageURL%3A%22http%3A//localhost%3A8080/BuiltInDS/BuiltInDS.html%22%2C%20%0D%20%20%20%20isc_pageGUID%3A%227CF1E373-8FA9-46C3-84DD-C631C5BF8DFE%22%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20sgwtInternal%3A1%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20left%3A492%2C%20%0D%20%20%20%20top%3A106%2C%20%0D%20%20%20%20width%3A1245%2C%20%0D%20%20%20%20height%3A746%0D%7D
      === 2015-08-20 10:39:26,693 [c-50] DEBUG IDACall - Header Name:Value pair: connection:keep-alive
      === 2015-08-20 10:39:26,693 [c-50] DEBUG IDACall - Header Name:Value pair: pragma:no-cache
      === 2015-08-20 10:39:26,693 [c-50] DEBUG IDACall - Header Name:Value pair: cache-control:no-cache
      === 2015-08-20 10:39:26,693 [c-50] DEBUG IDACall - session exists: F6688982F8C2D56B93A30CE0C6BFAFC9
      === 2015-08-20 10:39:26,693 [c-50] DEBUG IDACall - remote user: null
      === 2015-08-20 10:39:26,697 [c-50] DEBUG XML - Parsed XML from (in memory stream): 2ms
      === 2015-08-20 10:39:26,697 [c-50] DEBUG ISCKeyedObjectPool - Borrowing object for 'transaction'
      === 2015-08-20 10:39:26,698 [c-50] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'transaction' in the pooling flow
      === 2015-08-20 10:39:26,698 [c-50] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
      === 2015-08-20 10:39:26,698 [c-50] DEBUG PoolableDataSourceFactory - Created DataSource 51 of type 'Object' and assigned it to thread http-bio-8080-exec-50
      === 2015-08-20 10:39:26,698 [c-50] DEBUG PoolableDataSourceFactory - Created DataSource 51 of type 'Object' in the pooling flow
      === 2015-08-20 10:39:26,699 [c-50] DEBUG PoolableDataSourceFactory - Activated DataSource 51 of type 'Object'
      === 2015-08-20 10:39:26,699 [c-50] DEBUG ISCKeyedObjectPool - Borrowing object for 'List'
      === 2015-08-20 10:39:26,700 [c-50] DEBUG PoolableDataSourceFactory - Created DataSource 52 of type 'List' and assigned it to thread http-bio-8080-exec-50
      === 2015-08-20 10:39:26,700 [c-50] DEBUG PoolableDataSourceFactory - Created DataSource 52 of type 'List' in the pooling flow
      === 2015-08-20 10:39:26,700 [c-50] DEBUG PoolableDataSourceFactory - Activated DataSource 52 of type 'List'
      === 2015-08-20 10:39:26,701 [c-50] DEBUG ISCKeyedObjectPool - Borrowing object for 'elem'
      === 2015-08-20 10:39:26,701 [c-50] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'elem' in the pooling flow
      === 2015-08-20 10:39:26,702 [c-50] DEBUG RPCManager - Processing 1 requests.
      === 2015-08-20 10:39:26,702 [c-50] DEBUG ISCKeyedObjectPool - Borrowing object for 'T_SYS_DELETEALLOWEDTENANT'
      === 2015-08-20 10:39:26,702 [c-50] DEBUG PoolableDataSourceFactory - Activated DataSource 34 of type 'T_SYS_DELETEALLOWEDTENANT'
      === 2015-08-20 10:39:26,702 [c-50] DEBUG DSRequest - Caching instance 34 of DS 'T_SYS_DELETEALLOWEDTENANT' from DSRequest.getDataSource()
      === 2015-08-20 10:39:26,702 [c-50] DEBUG DSRequest - Caching instance 34 of DS T_SYS_DELETEALLOWEDTENANT
      === 2015-08-20 10:39:26,703 [c-50] DEBUG RPCManager - Request #1 (DSRequest) payload: {
          values:null,
          operationConfig:{
              dataSource:"T_SYS_DELETEALLOWEDTENANT",
              repo:null,
              operationType:"custom",
              textMatchStyle:"exact"
          },
          appID:"builtinApplication",
          operation:"badDelete",
          oldValues:null,
          criteria:{
          }
      }
      === 2015-08-20 10:39:26,703 [c-50] INFO  IDACall - Performing 1 operation(s)
      === 2015-08-20 10:39:26,703 [c-50] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
      === 2015-08-20 10:39:26,703 [c-50] DEBUG DeclarativeSecurity - DataSource T_SYS_DELETEALLOWEDTENANT is not in the pre-checked list, processing...
      === 2015-08-20 10:39:26,704 [c-50] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
      === 2015-08-20 10:39:26,705 [c-50] DEBUG ServerObject - Couldn't find a public method named: remove on class: com.smartgwt.sample.server.listener.T_SYS_DELETEALLOWEDTENANT
      === 2015-08-20 10:39:26,705 [c-50] DEBUG DataSourceDMI - DataSourceDMI: no public method name: remove available on class: com.smartgwt.sample.server.listener.T_SYS_DELETEALLOWEDTENANT - defaulting to builtin operations.
      === 2015-08-20 10:39:26,705 [c-50] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
      === 2015-08-20 10:39:26,705 [c-50] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
      === 2015-08-20 10:39:26,706 [c-50] INFO  SQLDataSource - [builtinApplication.null] Performing remove operation with
      	criteria: {criteria:[{value:12,fieldName:"TENANT_ID",operator:"equals"}],operator:"and",_constructor:"AdvancedCriteria"}	values: {criteria:[{value:12,fieldName:"TENANT_ID",operator:"equals"}],operator:"and",_constructor:"AdvancedCriteria"}
      === 2015-08-20 10:39:26,707 [c-50] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] Executing pingTest 'select 1 from dual' on connection 274822540
      === 2015-08-20 10:39:26,708 [c-50] DEBUG SQLConnectionManager - [builtinApplication.null] Borrowed connection '274822540'
      === 2015-08-20 10:39:26,708 [c-50] DEBUG SQLTransaction - [builtinApplication.null] Started new Oracle transaction "274822540"
      === 2015-08-20 10:39:26,709 [c-50] DEBUG SQLDriver - [builtinApplication.null] About to execute SQL update in 'Oracle' using connection'274822540'
      === 2015-08-20 10:39:26,709 [c-50] INFO  SQLDriver - [builtinApplication.null] Executing SQL update on 'Oracle': DELETE FROM T_SYS_DELETEALLOWEDTENANT WHERE ((T_SYS_DELETEALLOWEDTENANT.TENANT_ID = 12 AND T_SYS_DELETEALLOWEDTENANT.TENANT_ID IS NOT NULL))
      === 2015-08-20 10:39:26,710 [c-50] DEBUG SQLDataSource - [builtinApplication.null] remove operation affected 1 rows
      === 2015-08-20 10:39:26,711 [c-50] DEBUG SQLDriver - [builtinApplication.null] About to execute SQL query in 'Oracle' using connection '274822540'
      === 2015-08-20 10:39:26,711 [c-50] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'Oracle': SELECT T_SYS_DELETEALLOWEDTENANT_ID.CurrVal FROM DUAL
      === 2015-08-20 10:39:26,719 [c-50] DEBUG DSRequest - freeOnExecute is false for request of type remove on DataSource T_SYS_DELETEALLOWEDTENANT - not freeing resources!
      === 2015-08-20 10:39:26,722 [c-50] DEBUG DataSourceDMI - Invocation threw exception
      java.sql.SQLException: ORA-08002: sequence T_SYS_DELETEALLOWEDTENANT_ID.CURRVAL is not yet defined in this session
      
      	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
      	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
      	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
      	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
      	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
      	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
      	at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
      	at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:876)
      	at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1175)
      	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1296)
      	at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1498)
      	at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
      	at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
      	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:621)
      	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:550)
      	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:543)
      	at com.isomorphic.sql.SQLDriver.getScalarResult(SQLDriver.java:729)
      	at com.isomorphic.sql.OracleDriver.fetchLastPrimaryKeys(OracleDriver.java:243)
      	at com.isomorphic.sql.SQLDataSource.getLastPrimaryKeys(SQLDataSource.java:788)
      	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:2059)
      	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:444)
      	at com.isomorphic.sql.SQLDataSource.executeRemove(SQLDataSource.java:401)
      	at com.smartgwt.sample.server.listener.MySQLDataSource.executeRemove(MySQLDataSource.java:27)
      	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1958)
      	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:726)
      	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:2548)
      	at com.smartgwt.sample.server.listener.T_SYS_DELETEALLOWEDTENANT.badDelete(T_SYS_DELETEALLOWEDTENANT.java:26)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:975)
      	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:416)
      	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
      	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2544)
      	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:220)
      	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:185)
      	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:152)
      	at com.isomorphic.servlet.IDACall._processRequest(IDACall.java:117)
      	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:76)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:156)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at com.isomorphic.servlet.CompressionFilter._doFilter(CompressionFilter.java:260)
      	at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:83)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      === 2015-08-20 10:39:26,724 [c-50] DEBUG DSRequest - About to free up resources for request of type custom on DataSource T_SYS_DELETEALLOWEDTENANT
      === 2015-08-20 10:39:26,724 [c-50] DEBUG DSRequest - Ignoring freeResources call because this is not a primary request!
      === 2015-08-20 10:39:26,725 [c-50] WARN  RequestContext - dsRequest.execute() failed: 
      java.sql.SQLException: ORA-08002: sequence T_SYS_DELETEALLOWEDTENANT_ID.CURRVAL is not yet defined in this session
      
      	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
      	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
      	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
      	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
      	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
      	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
      	at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
      	at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:876)
      	at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1175)
      	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1296)
      	at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1498)
      	at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
      	at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
      	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:621)
      	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:550)
      	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:543)
      	at com.isomorphic.sql.SQLDriver.getScalarResult(SQLDriver.java:729)
      	at com.isomorphic.sql.OracleDriver.fetchLastPrimaryKeys(OracleDriver.java:243)
      	at com.isomorphic.sql.SQLDataSource.getLastPrimaryKeys(SQLDataSource.java:788)
      	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:2059)
      	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:444)
      	at com.isomorphic.sql.SQLDataSource.executeRemove(SQLDataSource.java:401)
      	at com.smartgwt.sample.server.listener.MySQLDataSource.executeRemove(MySQLDataSource.java:27)
      	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1958)
      	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:726)
      	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:2548)
      	at com.smartgwt.sample.server.listener.T_SYS_DELETEALLOWEDTENANT.badDelete(T_SYS_DELETEALLOWEDTENANT.java:26)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:975)
      	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:416)
      	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
      	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2544)
      	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:220)
      	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:185)
      	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:152)
      	at com.isomorphic.servlet.IDACall._processRequest(IDACall.java:117)
      	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:76)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:156)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at com.isomorphic.servlet.CompressionFilter._doFilter(CompressionFilter.java:260)
      	at com.isomorphic.servlet.BaseFilter.doFilter(BaseFilter.java:83)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      === 2015-08-20 10:39:26,728 [c-50] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2015-08-20 10:39:26,728 [c-50] DEBUG SQLTransaction - Rolling back Oracle transaction "274822540"
      === 2015-08-20 10:39:26,729 [c-50] DEBUG RPCManager - non-DMI response, dropExtraFields: false
      === 2015-08-20 10:39:26,730 [c-50] DEBUG DSRequest - Ignoring freeQueueResources call because this is not a primary request!
      === 2015-08-20 10:39:26,730 [c-50] DEBUG SQLTransaction - getConnection() found transactional connection for Oracle with hashcode "274822540"
      === 2015-08-20 10:39:26,730 [c-50] DEBUG SQLTransaction - Ending Oracle transaction "274822540"
      === 2015-08-20 10:39:26,731 [c-50] DEBUG SQLConnectionManager - About to close connection with hashcode "274822540"
      === 2015-08-20 10:39:26,731 [c-50] DEBUG PoolableSQLConnectionFactory - Executing pingTest 'select 1 from dual' on connection 274822540
      === 2015-08-20 10:39:26,732 [c-50] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 34 of type 'T_SYS_DELETEALLOWEDTENANT'
      === 2015-08-20 10:39:26,733 [c-50] INFO  Compression - /BuiltInDS/builtinds/sc/IDACall: 229 -> 200 bytes
      === 2015-08-20 10:39:27,380 [c-49] INFO  RequestContext - URL: '/BuiltInDS/builtinds/sc/skins/Simplicity/images/headerIcons/close.gif', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
      === 2015-08-20 10:39:27,380 [c-51] INFO  RequestContext - URL: '/BuiltInDS/builtinds/sc/skins/Simplicity/images/Dialog/warn.png', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
      === 2015-08-20 10:39:27,383 [c-49] INFO  Download - done streaming: C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/BuiltInDS/builtinds/sc/skins/Simplicity/images/headerIcons/close.gif
      === 2015-08-20 10:39:27,385 [c-51] INFO  Download - done streaming: C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/BuiltInDS/builtinds/sc/skins/Simplicity/images/Dialog/warn.png
      Tested using v10.0p_2015-08-18/PowerEdition Deployment.

      Best regards
      Blama

      Comment


        #18
        We appreciate the effort put into the test case, but why do all of that? If that bug is what you think it is, it should be able to be demonstrated with a trivial DMI added to the stock supplyItem.ds.xml from a showcase example - with a Server Script it would be a one-file test case with just a few lines of code added.

        All of this extra code leaves a lot of room for unrelated application bugs.

        Comment


          #19
          Hi Isomorphic,

          Originally posted by Isomorphic View Post
          We appreciate the effort put into the test case, but why do all of that? If that bug is what you think it is, it should be able to be demonstrated with a trivial DMI added to the stock supplyItem.ds.xml from a showcase example - with a Server Script it would be a one-file test case with just a few lines of code added.
          That is true for the WHERE-clause bug, but not the CurrVal-SELECT. For that, you need a Sequence-PK, which your animals.ds.xml etc don't have.
          Also I don't know if HSQLDB supports those, so I did not just add it, because the frameworks behaviour might be different for this DBMS. Also the DELETE needs to actually delete rows for the CurrVal-SELECT to trigger - so IMO there is no other way than running this on Oracle.

          OK, while writing this I see that supplyItem.ds.xml has a Sequence PK. Good to know.

          Best regards
          Blama

          Comment


            #20
            Can you try describing what you're calling the "CurrVal-SELECT" issue? We see you've got an exception from Oracle, but what are you claiming is the issue in SmartGWT that leads to this exception?

            At a glance, it looks like you declared the sequence by hand, but did not tell SmartGWT what the sequence name is via the dataSourceField.sequenceName attribute.

            Comment


              #21
              Hi Isomorphic,

              the sequence name is the name you use as default if no name is specified (here t_sys_deleteallowedtenant_id, see DDL in above post). No problem here.

              The problem is that the main DML-statement is a DELETE and not an INSERT, so there is no need for a CurrVal-SELECT at all. While this would not harm if used in mid application, it does harm if t_sys_deleteallowedtenant_id.NextVal was never called (see Oracle docs, search for chapter "Using Sequence Numbers with CURRVAL" in the text).
              This is the reason I used this old thread as before there was the same problem for an UPDATE-statement.

              So the sequence exists, but you can not and should SELECT CurrVal. Please note that this does not happen for the "goodDelete", so there is some bug here related to setAllowMultiUpdate(true) not being present.

              Perhaps the real error is also a bit before - the statement should not execute in the 1st place - no criteria for the PK field and setAllowMultiUpdate not set.

              Best regards
              Blama

              Comment


                #22
                Hi Isomorphic,

                could you look into this one already?

                Best regards
                Blama

                Comment


                  #23
                  Hi Blama,
                  We are - it's been under investigation for a while and we'll follow up when we have anything to share!

                  Regards
                  Isomorphic Software

                  Comment


                    #24
                    Apologies for the delay, the CurrVal-Select issue is fixed now, you may download next (2015-09-19 or newer) nightly build and try it out.

                    Comment


                      #25
                      Hi Isomorphic,

                      I'll retest with Monday's nightly. Did you also consider this idea:
                      Originally posted by Blama View Post
                      Perhaps the real error is also a bit before - the statement should not execute in the 1st place - no criteria for the PK field and setAllowMultiUpdate not set.
                      Best regards
                      Blama

                      Comment


                        #26
                        We did - we also introduced a new setting "defaultMultiUpdatePolicy" for when multi-updates are allowed (in the absence of an explicit allowMultiUpdate setting).

                        Comment

                        Working...
                        X