Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Bug in SQL Generation for UPDATE on a Oracle table with sequence-PK

$
0
0
Hi Isomorphic,

I found a server-side bug (using Oracle and a sequence-PK, see .ds.xml) in SNAPSHOT_v9.1d_2014-02-05/EVAL Deployment, which I wasn't able to reproduce, but perhaps you can find it anyway with the stack trace.
The problem is that the server issued a SELECT xxx.CurrVal FROM DUAL after an update in order to find a PK. This is wrong, even if it worked, but didn't work, as the sequence was not used in the session, yet (normal Oracle behavoir).

Server stack trace:
Code:

=== 2014-02-07 17:11:47,707 [c-34] 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-02-07 17:11:47,710 [c-34] DEBUG XML - Parsed XML from (in memory stream): 2ms
=== 2014-02-07 17:11:47,713 [c-34] DEBUG RPCManager - Processing 1 requests.
=== 2014-02-07 17:11:47,713 [c-34] DEBUG DSRequest - Caching instance 2140 of DS T_LEAD_ONLYRESELLER from DSRequest.getDataSource()
=== 2014-02-07 17:11:47,714 [c-34] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    criteria:{
        ID:2
    },
    values:{
        ID:2,
        RESELLER_ID:3,
        RESELLER_NAME:"3"
    },
    operationConfig:{
        dataSource:"T_LEAD_ONLYRESELLER",
        operationType:"update"
    },
    componentId:"isc_AddEditLeadReseller_5_0",
    appID:"builtinApplication",
    operation:"T_LEAD_ONLYRESELLER_update",
    oldValues:{
        RESELLER_TENANT_ID:0,
        RESELLER_NAME:"lore",
        LEAD_ID:4,
        RESELLER_ID:2,
        TENANT_ID:0,
        RESELLER_ZIPCODE:"76133",
        MODIFIED_AT:new Date(1391787742000),
        CREATED_BY:"1012",
        CREATED_AT:new Date(1391787742000),
        CREATED_BY_TENANT_ID:0,
        ID:2,
        MODIFIED_BY:"1012",
        MODIFIED_BY_TENANT_ID:0,
        RESELLER_CITY:"lore",
        ADDRESS_TENANT_ID:0
    }
}
=== 2014-02-07 17:11:47,714 [c-34] DEBUG Relation - Caching instance of toDS 'T_RESELLER' in the DSRequest map
=== 2014-02-07 17:11:47,714 [c-34] DEBUG Relation - Caching instance of toDS 'T_ADDRESS' in the DSRequest map
=== 2014-02-07 17:11:47,715 [c-34] DEBUG Relation - Caching instance of toDS 'V_USER_CREATED_BY' in the DSRequest map
=== 2014-02-07 17:11:47,715 [c-34] DEBUG Relation - Caching instance of toDS 'V_USER_MODIFIED_BY' in the DSRequest map
=== 2014-02-07 17:11:47,715 [c-34] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
=== 2014-02-07 17:11:47,715 [c-34] DEBUG DeclarativeSecurity - DataSource T_LEAD_ONLYRESELLER is not in the pre-checked list, processing...
=== 2014-02-07 17:11:47,716 [c-34] DEBUG AppBase - [builtinApplication.T_LEAD_ONLYRESELLER_update] No userTypes defined, allowing anyone access to all operations for this application
=== 2014-02-07 17:11:47,716 [c-34] DEBUG AppBase - [builtinApplication.T_LEAD_ONLYRESELLER_update] No public zero-argument method named '_T_LEAD_ONLYRESELLER_update' found, performing generic datasource operation
=== 2014-02-07 17:11:47,721 [c-34] INFO  SQLDataSource - [builtinApplication.T_LEAD_ONLYRESELLER_update] Performing update operation with
        criteria: {criteria:[{value:2,fieldName:"ID",operator:"equals"},{value:0,fieldName:"TENANT_ID",operator:"equals"}],operator:"and",_constructor:"AdvancedCriteria"}        values: {ID:2,RESELLER_ID:3,RESELLER_NAME:"3",MODIFIED_BY:"1012",MODIFIED_AT:new Date(1391789507715)}
=== 2014-02-07 17:11:47,721 [c-34] INFO  SQLValuesClause - [builtinApplication.T_LEAD_ONLYRESELLER_update] Ignored data for non-existent or included columns: [RESELLER_NAME]
=== 2014-02-07 17:11:47,723 [c-34] DEBUG PoolableSQLConnectionFactory - [builtinApplication.T_LEAD_ONLYRESELLER_update] Executing pingTest 'select 1 from dual' on connection 13716197
=== 2014-02-07 17:11:47,724 [c-34] DEBUG SQLConnectionManager - [builtinApplication.T_LEAD_ONLYRESELLER_update] Borrowed connection '13716197'
=== 2014-02-07 17:11:47,724 [c-34] DEBUG SQLTransaction - [builtinApplication.T_LEAD_ONLYRESELLER_update] Started new Oracle transaction "13716197"
=== 2014-02-07 17:11:47,724 [c-34] DEBUG SQLDriver - [builtinApplication.T_LEAD_ONLYRESELLER_update] About to execute SQL update in 'Oracle' using connection'13716197'
=== 2014-02-07 17:11:47,724 [c-34] INFO  SQLDriver - [builtinApplication.T_LEAD_ONLYRESELLER_update] Executing SQL update on 'Oracle': UPDATE T_LEAD_ONLYRESELLER SET MODIFIED_AT=TO_DATE('2014-02-07 17:11:47','YYYY-MM-DD HH24:MI:SS'), MODIFIED_BY='1012', RESELLER_ID=3 WHERE ((T_LEAD_ONLYRESELLER.ID = 2 AND T_LEAD_ONLYRESELLER.ID IS NOT NULL) AND (T_LEAD_ONLYRESELLER.TENANT_ID = 0 AND T_LEAD_ONLYRESELLER.TENANT_ID IS NOT NULL))
=== 2014-02-07 17:11:47,729 [c-34] DEBUG SQLDataSource - [builtinApplication.T_LEAD_ONLYRESELLER_update] update operation affected 1 rows
=== 2014-02-07 17:11:47,729 [c-34] DEBUG SQLDriver - [builtinApplication.T_LEAD_ONLYRESELLER_update] About to execute SQL query in 'Oracle' using connection '13716197'
=== 2014-02-07 17:11:47,730 [c-34] INFO  SQLDriver - [builtinApplication.T_LEAD_ONLYRESELLER_update] Executing SQL query on 'Oracle': SELECT T_LEAD_ONLYRESELLER_ID.CurrVal FROM DUAL
=== 2014-02-07 17:11:47,733 [c-34] WARN  RequestContext - dsRequest.execute() failed:
java.sql.SQLException: ORA-08002: sequence T_LEAD_ONLYRESELLER_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:605)
        at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:534)
        at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:527)
        at com.isomorphic.sql.SQLDriver.getScalarResult(SQLDriver.java:691)
        at com.isomorphic.sql.OracleDriver.fetchLastPrimaryKeys(OracleDriver.java:243)
        at com.isomorphic.sql.SQLDataSource.getLastPrimaryKeys(SQLDataSource.java:719)
        at com.isomorphic.sql.SQLDataSource.getLastRow(SQLDataSource.java:595)
        at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1966)
        at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:411)
        at com.isomorphic.sql.SQLDataSource.executeUpdate(SQLDataSource.java:360)
        at com.lmscompany.lms.server.LMSSQLDataSource.executeUpdate(LMSSQLDataSource.java:50)
        at com.isomorphic.datasource.DataSource.execute(DataSource.java:1532)
        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:2565)
        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: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)

.ds.xml
Code:

<DataSource dbName="Oracle" tableName="T_LEAD_ONLYRESELLER" ID="T_LEAD_ONLYRESELLER" 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" title="LEAD_ID" type="integer" />
                <field foreignKey="T_RESELLER.ID" name="RESELLER_ID" title="Reseller" type="integer" displayField="RESELLER_NAME" />
                <field name="RESELLER_NAME" includeFrom="T_RESELLER.NAME" hidden="true" />
                <field name="RESELLER_ZIPCODE" includeFrom="T_ADDRESS.ZIPCODE" includeVia="RESELLER_ID" />
                <field name="RESELLER_CITY" includeFrom="T_ADDRESS.CITY" includeVia="RESELLER_ID" />
               
                <!-- TENANT_IDs for WHERE-clause generation -->
                <field name="CREATED_BY_TENANT_ID" includeFrom="V_USER_CREATED_BY.TENANT_ID" hidden="true" />
                <field name="MODIFIED_BY_TENANT_ID" includeFrom="V_USER_MODIFIED_BY.TENANT_ID" hidden="true" />
                <field name="RESELLER_TENANT_ID" includeFrom="T_RESELLER.TENANT_ID" hidden="true" />
                <field name="ADDRESS_TENANT_ID" includeFrom="T_ADDRESS.TENANT_ID" includeVia="RESELLER_ID" hidden="true" />
        </fields>
</DataSource>

Best regards,
Blama

Viewing all articles
Browse latest Browse all 4756

Trending Articles