Announcement

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

    Serverside bug in DSRequest.setAdvancedCriteria() resulting in unbounded DELETE

    Hi Isomorphic,

    I'm using v9.1p_2014-06-29 (With FF26, Oracle 11gR2 XE, Tomcat 7, Java 7) and get following server-side bug related to DSRequest.setAdvancedCriteria(new AdvancedCriteria(...)).

    The Criteria are not set correctly, resulting in
    • A delete with to few criteria (no PK), even though setAllowMultiUpdate is not set!
    • A useless and exception creating "SELECT T_LEAD_PRODUCTINTEREST_ID.CurrVal FROM DUAL" (not suitable after a DELETE)


    Here all you might need:

    Client request:
    Code:
    {
        dataSource:"V_LEAD_PRODUCT_ASSIGNED", 
        operationType:"remove", 
        componentId:"isc_AddEditLeadProductInterest_2_5", 
        data:{
            LEAD_PRODUCTINTEREST_ID:4, 
            PRODUCT_ID:4, 
            PRODUCT_NAME:"Middleware", 
            LEAD_ID:36, 
            PRODUCTCATEGORY_NAME:"Jboss", 
            PRODUCTCATEGORY_ID:3, 
            TENANT_ID:2, 
            PRODUCT_AVAILABLE:true
        }, 
        textMatchStyle:"exact", 
        callback:{
            target:[ListGrid ID:isc_AddEditLeadProductInterest_2_5], 
            methodName:"removeDataComplete"
        }, 
        showPrompt:false, 
        oldValues:{
            LEAD_PRODUCTINTEREST_ID:4, 
            PRODUCT_ID:4, 
            PRODUCT_NAME:"Middleware", 
            LEAD_ID:36, 
            PRODUCTCATEGORY_NAME:"Jboss", 
            PRODUCTCATEGORY_ID:3, 
            TENANT_ID:2, 
            PRODUCT_AVAILABLE:true
        }, 
        requestId:"V_LEAD_PRODUCT_ASSIGNED$62777", 
        internalClientContext:{
            removeDataCallback:"isc_AddEditLeadProductInterest_2_5.showRemoveCompleteAnimation(1, data,dsResponse);", 
            editInfo:{
                fromUserAction:true, 
                rowNum:1, 
                values:Obj, 
                editCompletionEvent:"programmatic"
            }
        }, 
        fallbackToEval:false, 
        lastClientEventThreadCode:"TMR0", 
        bypassCache:true
    }
    Server log:
    Code:
    === 2014-07-01 17:18:08,219 [ec-5] INFO  RequestContext - URL: '/lms/lms/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
    === 2014-07-01 17:18:08,224 [ec-5] DEBUG XML - Parsed XML from (in memory stream): 3ms
    === 2014-07-01 17:18:08,224 [ec-5] DEBUG ISCKeyedObjectPool - Borrowing object for 'transaction'
    === 2014-07-01 17:18:08,225 [ec-5] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2014-07-01 17:18:08,226 [ec-5] DEBUG ISCKeyedObjectPool - Borrowing object for 'List'
    === 2014-07-01 17:18:08,227 [ec-5] DEBUG ISCKeyedObjectPool - Borrowing object for 'elem'
    === 2014-07-01 17:18:08,230 [ec-5] DEBUG RPCManager - Processing 1 requests.
    === 2014-07-01 17:18:08,230 [ec-5] DEBUG ISCKeyedObjectPool - Borrowing object for 'V_LEAD_PRODUCT_ASSIGNED'
    === 2014-07-01 17:18:08,230 [ec-5] DEBUG DSRequest - Caching instance 509 of DS V_LEAD_PRODUCT_ASSIGNED from DSRequest.getDataSource()
    === 2014-07-01 17:18:08,231 [ec-5] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{
            LEAD_PRODUCTINTEREST_ID:4,
            PRODUCT_ID:4,
            PRODUCT_NAME:"Middleware",
            LEAD_ID:36,
            PRODUCTCATEGORY_NAME:"Jboss",
            PRODUCTCATEGORY_ID:3,
            TENANT_ID:2,
            PRODUCT_AVAILABLE:true,
            _selection_71:true
        },
        operationConfig:{
            dataSource:"V_LEAD_PRODUCT_ASSIGNED",
            operationType:"remove",
            textMatchStyle:"exact"
        },
        componentId:"isc_AddEditLeadProductInterest_2_5",
        appID:"builtinApplication",
        operation:"V_LEAD_PRODUCT_ASSIGNED_remove",
        oldValues:{
            LEAD_PRODUCTINTEREST_ID:4,
            PRODUCT_ID:4,
            PRODUCT_NAME:"Middleware",
            LEAD_ID:36,
            PRODUCTCATEGORY_NAME:"Jboss",
            PRODUCTCATEGORY_ID:3,
            TENANT_ID:2,
            PRODUCT_AVAILABLE:true,
            _selection_71:true
        }
    }
    === 2014-07-01 17:18:08,231 [ec-5] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2014-07-01 17:18:08,231 [ec-5] DEBUG DeclarativeSecurity - DataSource V_LEAD_PRODUCT_ASSIGNED is not in the pre-checked list, processing...
    === 2014-07-01 17:18:10,885 [ec-5] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2014-07-01 17:18:10,885 [ec-5] DEBUG ISCKeyedObjectPool - Borrowing object for 'T_LEAD_PRODUCTINTEREST'
    === 2014-07-01 17:18:10,886 [ec-5] DEBUG DSRequest - Caching instance 177 of DS T_LEAD_PRODUCTINTEREST from DSRequest.getDataSource()
    === 2014-07-01 17:18:10,886 [ec-5] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2014-07-01 17:18:10,886 [ec-5] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2014-07-01 17:18:10,887 [ec-5] INFO  SQLDataSource - [builtinApplication.null] Performing remove operation with
    	criteria: {TENANT_ID:2}	values: {TENANT_ID:2}
    === 2014-07-01 17:18:10,888 [ec-5] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] Connection was already closed in validateObject - returning false
    === 2014-07-01 17:18:10,922 [ec-5] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] makeObject() created a pooled Connection '1606697951'
    === 2014-07-01 17:18:10,922 [ec-5] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] Executing pingTest 'select 1 from dual' on connection 1606697951
    === 2014-07-01 17:18:10,924 [ec-5] DEBUG SQLConnectionManager - [builtinApplication.null] Borrowed connection '1606697951'
    === 2014-07-01 17:18:10,924 [ec-5] DEBUG SQLTransaction - [builtinApplication.null] Started new Oracle transaction "1606697951"
    === 2014-07-01 17:18:10,924 [ec-5] DEBUG SQLDriver - [builtinApplication.null] About to execute SQL update in 'Oracle' using connection'1606697951'
    === 2014-07-01 17:18:10,924 [ec-5] INFO  SQLDriver - [builtinApplication.null] Executing SQL update on 'Oracle': DELETE FROM T_LEAD_PRODUCTINTEREST WHERE (T_LEAD_PRODUCTINTEREST.TENANT_ID=2)
    === 2014-07-01 17:18:10,925 [ec-5] DEBUG SQLDataSource - [builtinApplication.null] remove operation affected 2 rows
    === 2014-07-01 17:18:10,925 [ec-5] DEBUG SQLDriver - [builtinApplication.null] About to execute SQL query in 'Oracle' using connection '1606697951'
    === 2014-07-01 17:18:10,926 [ec-5] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'Oracle': SELECT T_LEAD_PRODUCTINTEREST_ID.CurrVal FROM DUAL
    === 2014-07-01 17:18:10,927 [ec-5] DEBUG DataSourceDMI - Invocation threw exception
    java.sql.SQLException: ORA-08002: sequence T_LEAD_PRODUCTINTEREST_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:619)
    	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:548)
    	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:541)
    	at com.isomorphic.sql.SQLDriver.getScalarResult(SQLDriver.java:705)
    	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:1985)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:444)
    	at com.isomorphic.sql.SQLDataSource.executeRemove(SQLDataSource.java:401)
    	at com.lmscompany.lms.server.LMSSQLDataSource.executeRemove(LMSSQLDataSource.java:54)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1552)
    	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:723)
    	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:2553)
    	at com.lmscompany.lms.server.worker.V_LEAD_PRODUCT_ASSIGNED.remove(V_LEAD_PRODUCT_ASSIGNED.java:33)
    	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:2549)
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:172)
    	at com.lmscompany.lms.server.LMSIDACall.processRequest(LMSIDACall.java:33)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	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 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:611)
    	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:313)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    === 2014-07-01 17:18:10,930 [ec-5] WARN  RequestContext - dsRequest.execute() failed: 
    java.sql.SQLException: ORA-08002: sequence T_LEAD_PRODUCTINTEREST_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:619)
    	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:548)
    	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:541)
    	at com.isomorphic.sql.SQLDriver.getScalarResult(SQLDriver.java:705)
    	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:1985)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:444)
    	at com.isomorphic.sql.SQLDataSource.executeRemove(SQLDataSource.java:401)
    	at com.lmscompany.lms.server.LMSSQLDataSource.executeRemove(LMSSQLDataSource.java:54)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1552)
    	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:723)
    	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:2553)
    	at com.lmscompany.lms.server.worker.V_LEAD_PRODUCT_ASSIGNED.remove(V_LEAD_PRODUCT_ASSIGNED.java:33)
    	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:2549)
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:172)
    	at com.lmscompany.lms.server.LMSIDACall.processRequest(LMSIDACall.java:33)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	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 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:611)
    	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:313)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    === 2014-07-01 17:18:10,932 [ec-5] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
    === 2014-07-01 17:18:10,932 [ec-5] DEBUG SQLTransaction - Rolling back Oracle transaction "1606697951"
    === 2014-07-01 17:18:10,933 [ec-5] DEBUG RPCManager - non-DMI response, dropExtraFields: false
    === 2014-07-01 17:18:10,934 [ec-5] DEBUG SQLTransaction - getConnection() found transactional connection for Oracle with hashcode "1606697951"
    === 2014-07-01 17:18:10,934 [ec-5] DEBUG SQLTransaction - Ending Oracle transaction "1606697951"
    === 2014-07-01 17:18:10,934 [ec-5] DEBUG SQLConnectionManager - About to close ISCPoolableConnection with hashcode "1606697951"
    === 2014-07-01 17:18:10,935 [ec-5] DEBUG PoolableSQLConnectionFactory - Executing pingTest 'select 1 from dual' on connection 1606697951
    === 2014-07-01 17:18:10,936 [ec-5] INFO  Compression - /lms/lms/sc/IDACall: 226 -> 197 bytes
    V_LEAD_PRODUCT_ASSIGNED.ds.xml (accessed by the client)
    Code:
    <DataSource dbName="Oracle" tableName="V_LEAD_PRODUCT_ASSIGNED" ID="V_LEAD_PRODUCT_ASSIGNED"
    	serverType="sql" serverConstructor="com.lmscompany.lms.server.LMSSQLDataSource">
    	<fields>
    		<field hidden="true" name="TENANT_ID" type="integer" />
    		<field name="LEAD_PRODUCTINTEREST_ID" type="integer" hidden="true" />
    		<field primaryKey="true" name="LEAD_ID" type="integer" />
    		<field primaryKey="true" name="PRODUCT_ID" type="integer" displayField="PRODUCT_NAME" />
    		<field name="PRODUCT_NAME" length="60" type="text" hidden="true" />
    		<field name="PRODUCT_AVAILABLE" length="1" type="boolean" sqlStorageStrategy="singleCharYN" />
    		<field name="PRODUCTCATEGORY_ID" type="integer" displayField="PRODUCTCATEGORY_NAME" />
    		<field name="PRODUCTCATEGORY_NAME" length="60" type="text" hidden="true" />
    	</fields>
    	<serverObject lookupStyle="new" className="com.lmscompany.lms.server.worker.V_LEAD_PRODUCT_ASSIGNED" />
    	<operationBindings>
    		<operationBinding operationType="update" requiresRole="readonly" />
    		<operationBinding operationType="add" />
    		<operationBinding operationType="remove" />
    		<operationBinding operationType="fetch" />
    		<operationBinding operationType="fetch" operationId="assignedProducts">
    			<whereClause>LEAD_PRODUCTINTEREST_ID IS NOT NULL AND ($defaultWhereClause)</whereClause>
    		</operationBinding>
    		<operationBinding operationType="fetch" operationId="unassignedProducts">
    			<whereClause>LEAD_PRODUCTINTEREST_ID IS NULL AND PRODUCT_AVAILABLE = 'Y' AND ($defaultWhereClause)</whereClause>
    		</operationBinding>
    	</operationBindings>
    </DataSource>
    LMSSQLDataSource (adds the tenant_id-criteria, most likely not needed, included for completeness)
    Code:
    package com.lmscompany.lms.server;
    
    import java.util.Map;
    
    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;
    import com.lmscompany.lms.server.util.User;
    
    public class LMSSQLDataSource 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 executeAdd(DSRequest req) throws Exception {
    		@SuppressWarnings("unchecked")
    		Map<String, Object> requestValues = req.getValues();
    		requestValues.put("TENANT_ID", User.getUserTenantId(req.getHttpServletRequest()));
    		req.setValues(requestValues);
    		return super.executeAdd(req);
    	};
    
    	@Override
    	public DSResponse executeFetch(DSRequest dsRequest) throws Exception {
    		// T_USER.fetchUserIdForLoginname occurs before session parameters are set,
    		// so do not try to modify.
    		if (!dsRequest.getDataSourceName().equals("T_USER") || !dsRequest.getOperationId().equals("fetchUserIdForLoginname"))
    			modifyCriteria(dsRequest);
    		return super.executeFetch(dsRequest);
    	}
    
    	@Override
    	public DSResponse executeUpdate(DSRequest req) throws Exception {
    		modifyCriteria(req);
    		return super.executeUpdate(req);
    	}
    
    	@Override
    	public DSResponse executeRemove(DSRequest req) throws Exception {
    		modifyCriteria(req);
    		return super.executeRemove(req);
    	}
    
    	private static DSRequest modifyCriteria(DSRequest dsRequest) throws Exception {
    		// Add "TENANT_ID = x" - Criteria for fetch/update/remove
    		if (dsRequest.getOperationType().equals(DataSource.OP_FETCH) || dsRequest.getOperationType().equals(DataSource.OP_UPDATE)
    				|| dsRequest.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()));
    			dsRequest.addToCriteria("TENANT_ID", User.getUserTenantId(dsRequest.getHttpServletRequest()));
    			// Add additional "xyz_TENANT_ID = x" - Criteria for fetch for
    			// "includeFrom"-fields
    			if (dsRequest.getOperationType().equals(DataSource.OP_FETCH)) {
    				for (Object fn : dsRequest.getDataSource().getFieldNames()) {
    					String fieldName = fn.toString();
    					if ((dsRequest.getConsolidatedOutputs() == null || dsRequest.getConsolidatedOutputs().contains(fn))
    							&& fieldName.endsWith("_TENANT_ID")) {
    						if (!isOuterJoined(fieldName, dsRequest.getDataSource())) {
    							dsRequest.addToCriteria(fieldName, DefaultOperators.Equals, User.getUserTenantId(dsRequest.getHttpServletRequest()));
    						} else {
    							AdvancedCriteria ac = new AdvancedCriteria(DefaultOperators.Or, new Criterion[] {
    									new SimpleCriterion(fieldName, DefaultOperators.Equals, User.getUserTenantId(dsRequest.getHttpServletRequest())),
    									new IsNullCriterion(fieldName) });
    							dsRequest.addToCriteria(ac);
    						}
    					}
    				}
    			}
    		}
    		return dsRequest;
    	}
    
    	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;
    	}
    }
    V_LEAD_PRODUCT_ASSIGNED.java (the ServerConstructor), see bold part (commented out setCriteria() works, setAdvancedCriteria() does not).
    Code:
    package com.lmscompany.lms.server.worker;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import com.isomorphic.criteria.AdvancedCriteria;
    import com.isomorphic.criteria.Criterion;
    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;
    import com.lmscompany.lms.server.util.Helper;
    import com.lmscompany.lms.shared.type.DatasourceEnum;
    
    import javax.servlet.http.HttpServletRequest;
    
    public class V_LEAD_PRODUCT_ASSIGNED {
    
    	private Long leadId = null;
    	private Long productId = null;
    	private Long leadProductinterestId = null;
    
    	public DSResponse remove(DSRequest dsRequest, HttpServletRequest servletRequest) throws Exception {
    		DSResponse tryExtract = extractRequestData(dsRequest);
    		if (tryExtract != null)
    			return tryExtract;
    
    		DSRequest removeProductFromLeadRequest = new DSRequest(DatasourceEnum.T_LEAD_PRODUCTINTEREST.getValue(), DataSource.OP_REMOVE, dsRequest.getRPCManager());
    		[B]removeProductFromLeadRequest.setAdvancedCriteria(new AdvancedCriteria(new SimpleCriterion("ID", DefaultOperators.Equals,
    				leadProductinterestId)));
    //		removeProductFromLeadRequest.setCriteria("ID", leadProductinterestId);[/B]
    		DSResponse removeProductFromLeadResponse = removeProductFromLeadRequest.execute();
    
    		if (Helper.oneRow(removeProductFromLeadResponse)) {
    			DSRequest getNewViewStatusRequest = new DSRequest(DatasourceEnum.V_LEAD_PRODUCT_ASSIGNED.getValue(), DataSource.OP_FETCH, dsRequest.getRPCManager());
    			getNewViewStatusRequest.setAdvancedCriteria(new AdvancedCriteria(DefaultOperators.And, new Criterion[] {
    					new SimpleCriterion("LEAD_ID", DefaultOperators.Equals, leadId),
    					new SimpleCriterion("PRODUCT_ID", DefaultOperators.Equals, productId) }));
    			return getNewViewStatusRequest.execute();
    		} else
    			return new DSResponse().setFailure("Es ist ein Fehler beim Löschen der Produktzuordnung aufgetreten!");
    	}
    	
    	public DSResponse add(DSRequest dsRequest, HttpServletRequest servletRequest) throws Exception {
    		DSResponse tryExtract = extractRequestData(dsRequest);
    		if (tryExtract != null)
    			return tryExtract;
    
    		DSRequest addProductToLeadRequest = new DSRequest(DatasourceEnum.T_LEAD_PRODUCTINTEREST.getValue(), DataSource.OP_ADD, dsRequest.getRPCManager());
    		Map<String, Object> newEntry = new HashMap<String, Object>();
    		newEntry.put("LEAD_ID", leadId);
    		newEntry.put("PRODUCT_ID", productId);
    		addProductToLeadRequest.setValues(newEntry);
    		
    		DSResponse addProducttoLeadResponse = addProductToLeadRequest.execute();
    
    		if (Helper.oneRow(addProducttoLeadResponse)) {
    			DSRequest getNewViewStatusRequest = new DSRequest(DatasourceEnum.V_LEAD_PRODUCT_ASSIGNED.getValue(), DataSource.OP_FETCH, dsRequest.getRPCManager());
    			getNewViewStatusRequest.setAdvancedCriteria(new AdvancedCriteria(DefaultOperators.And, new Criterion[] {
    					new SimpleCriterion("LEAD_ID", DefaultOperators.Equals, leadId),
    					new SimpleCriterion("PRODUCT_ID", DefaultOperators.Equals, productId) }));
    			return getNewViewStatusRequest.execute();
    		} else
    			return new DSResponse().setFailure("Es ist ein Fehler beim Löschen der Produktzuordnung aufgetreten!");
    	}
    
    	private DSResponse extractRequestData(DSRequest dsRequest) {
    		if (dsRequest.getOperationType().equals(DataSource.OP_REMOVE)) {
    			try {
    				leadProductinterestId = new Long(dsRequest.getOldValues().get("LEAD_PRODUCTINTEREST_ID").toString());
    			} catch (Exception e) {
    			}
    			if (leadProductinterestId == null)
    				return new DSResponse().setFailure("Bitte einen Eintrag aus der Liste der zugeordneten Produkte auswählen!");
    		}
    
    		try {
    			leadId = new Long(dsRequest.getFieldValue("LEAD_ID").toString());
    		} catch (Exception e) {
    		}
    		if (leadId == null)
    			return new DSResponse().setFailure("Es ist keine Lead-Information vorhanden!");
    
    		try {
    			productId = new Long(dsRequest.getFieldValue("PRODUCT_ID").toString());
    		} catch (Exception e) {
    		}
    		if (productId == null)
    			return new DSResponse().setFailure("Es ist keine Produkt-Information vorhanden!");
    
    		return null;
    	}
    };
    T_LEAD_PRODUCTINTEREST.ds.xml (DELETE is done on this DS)
    Code:
    <DataSource dbName="Oracle" tableName="T_LEAD_PRODUCTINTEREST" ID="T_LEAD_PRODUCTINTEREST"
    	serverType="sql" serverConstructor="com.lmscompany.lms.server.LMSSQLDataSource">
    	<fields>
    		<field primaryKey="true" hidden="true" name="ID" type="sequence" />
    		<field hidden="true" name="TENANT_ID" type="integer" canEdit="false" />
    		<field foreignKey="V_USER_CREATED_BY.ID" name="CREATED_BY" title="Erstellt von" type="creator" />
    		<field name="CREATED_AT" title="Erstellt am" type="creatorTimestamp" />
    		<field foreignKey="V_USER_MODIFIED_BY.ID" name="MODIFIED_BY" title="Geändert von" type="modifier" />
    		<field name="MODIFIED_AT" title="Geändert am" type="modifierTimestamp" />
    		<field foreignKey="T_LEAD.ID" name="LEAD_ID" type="integer" />
    		<field foreignKey="T_PRODUCT.ID" name="PRODUCT_ID" type="integer" />
    	</fields>
    </DataSource>
    Basically, the bug is with setAdvancedCriteria() and you should not need my code to get to the problem.

    Best regards,
    Blama

    #2
    Thanks for reporting, this indeed was a bug.
    It is fixed now, you may download next nightly build (2014-06-08) and try it out.

    Comment


      #3
      Hi Isomorphic,

      this is fixed for me now, using v9.1p_2014-07-08.

      Thank you & Best regards,
      Blama

      Comment

      Working...
      X