Announcement

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

    isUnique validator with criteriaFields and grid updates

    SmartClient Version: v10.0p_2014-12-17/EVAL Deployment (expires 2015.02.15_07.40.12) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Hello, I'm using a 'isUnique' validator with a criteriaFields specifying 3 fields and it works flawlessly while adding a record to a grid.

    But when updating a record, if I modify only one of those three fields, the other two aren't submitted (as usual when updating records of a grid), and the select query to check for uniqueness is formed using nulls for those two fields.

    Is it expected behavior that the validator can't handle this use case? Or is it a bug?

    #2
    Thank's for sending us a report on this.

    We're having a look, right now it looks like a bug where the criteriaFields are not included from the existing record during an update but rather from the incoming record.

    Regards,
    Isormophic Software

    Comment


      #3
      Could you please provide a copy of your datasource xml definition file?

      Thanks,
      Isomorphic Software

      Comment


        #4
        this is the dataSource for the updateOperation:
        Code:
        <!--
         <%@page pageEncoding="UTF-8" contentType="text/xml; charset=UTF-8"%>
         <%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
         <fmt:setBundle basename="i18nMessages_${locale}" var="i18n"/>
         -->
        <DataSource xmlns="http://www.smartclient.com/schema"
                    ID="JAS_APPARTENENZA_SQUADRA"
                    tableName="JAS_APPARTENENZA_SQUADRA"
                    schema="DBJAS"
                    dbName="dbJas"
                    serverType="sql"
                    dropExtraFields="false"
                    requiresAuthentication="false"
                    inheritsFrom="JAS_APPARTENENZA_SQUADRA_BASE"
                >
            <fields>
                <field name="SOCIETA" type="text" customSQL="true">
                    <customSelectExpression>
                        (
                            SELECT JSO_INT.DESCRIZIONE
                            FROM JAS_SQUADRE JSQ_INT, JAS_SOCIETA JSO_INT
                            WHERE
                                JAS_APPARTENENZA_SQUADRA.ID_SQUADRA_FK = JSQ_INT.ID_REC
                                AND JSQ_INT.ID_SOCIETA_FK = JSO_INT.ID_REC
                        )
                    </customSelectExpression>
                </field>
                <field name="CATEGORIA" type="integer" customSQL="true" includeFrom="JAS_SQUADRE.ID_CATEGORIA_FK"
                       includeVia="ID_SQUADRA_FK"></field>
                <field name="CATEGORIA_DESC" type="text" customSQL="true">
                    <customSelectExpression>
                        (
                            SELECT JCS_INT.CATEGORIA
                            FROM JAS_CATEGORIE_SQUADRE JCS_INT
                            WHERE JCS_INT.ID_REC = JAS_SQUADRE.ID_CATEGORIA_FK
                        )
                    </customSelectExpression>
                </field>
        
                <field name="COGNOME_NOME" type="text" includeFrom="JAS_ANAGRAFICA_GIOCATORI.COGNOME_NOME"
                       includeVia="ID_GIOCATORE_FK" customSQL="true"/>
                <field name="DATA_STAGIONE" includeFrom="JAS_STAGIONI.DATA_INIZIO" type="text" canEdit="false" customSQL="true" />
            </fields>
            <operationBindings>
        <!-- ... operation bindings for fetch operations -->
            </operationBindings>
        </DataSource>
        which inherits from:
        Code:
        <!--
         <%@page pageEncoding="UTF-8" contentType="text/xml; charset=UTF-8"%>
         <%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
         <fmt:setBundle basename="i18nMessages_${locale}" var="i18n"/>
         -->
        <DataSource xmlns="http://www.smartclient.com/schema" xmlns:fmt="urn:jsptld:/WEB-INF/fmt.tld"
                    ID="JAS_APPARTENENZA_SQUADRA_BASE"
                    tableName="JAS_APPARTENENZA_SQUADRA"
                    schema="DBJAS"
                    dbName="dbJas"
                    serverType="sql"
                >
            <fields>
                <field sqlType="decimal" primaryKey="true" name="ID_REC" type="sequence" hidden="true"
                       sequenceName="SEQUENCE_ID_REC"></field>
                <field nativeFK="JAS_STAGIONI.ID_REC" foreignKey="JAS_STAGIONI.ID_REC" sqlType="decimal"
                       sqlLength="0" name="ID_STAGIONE_FK" type="integer" optionDataSource="JAS_STAGIONI"
                       displayField="DESCRIZIONE" valueField="ID_REC" title="Stagione" required="true">
                </field>
                <field nativeFK="JAS_ANAGRAFICA_GIOCATORI.ID_REC" foreignKey="JAS_ANAGRAFICA_GIOCATORI.ID_REC" sqlType="decimal"
                       sqlLength="0" name="ID_GIOCATORE_FK" type="integer" optionDataSource="JAS_ANAGRAFICA_GIOCATORI"
                       optionOperationId="fetchAll" displayField="COGNOME_NOME" valueField="ID_REC" title="Calciatore"
                       required="true" relatedTableAlias="JAS_ANAGRAFICA_GIOCATORI"></field>
                <field foreignKey="JAS_SQUADRE.ID_REC" sqlType="decimal" title="Squadra" required="true"
                       name="ID_SQUADRA_FK" type="integer" relatedTableAlias="JAS_SQUADRE" editorType="SelectItem"></field>
                <field sqlType="varchar" sqlLength="20" name="RUOLO" length="20" type="text" editorType="SelectItem">
                    <valueMap>
                        <value ID="ATT">Attaccante</value>
                        <value ID="CC">CentroCampista</value>
                        <value ID="DIF">Difensore</value>
                        <value ID="POR">Portiere</value>
                    </valueMap>
                </field>
                <field sqlType="decimal" sqlLength="3" name="NUM_MAGLIA" length="3" type="integer"></field>
                <field sqlType="decimal" sqlLength="3" name="NUM_MAGLIA_UEFA" length="3" type="integer"></field>
                <field name="DATA_APPARTENENZA_SQ" type="date" title="Dal" required="true">
                    <validators>
                        <validator type="isUnique" criteriaFields="ID_GIOCATORE_FK, DATA_APPARTENENZA_SQ, ID_STAGIONE_FK,
                                   ID_SQUADRA_FK" errorMessage="Non è possibile inserire la stessa data di appartenenza squadra
                                   per la stessa stagione e stessa squadra già precedentemente inseriti"/>
                    </validators>
                </field>
                <field name="NOTE" type="text" length="200" sqlLength="200" sqlType="varchar"/>
                <field sqlType="varchar" sqlLength="60" name="CREATOR" length="60" type="creator"></field>
                <field sqlType="timestamp" sqlLength="11" name="DATE_CREATOR" type="creatorTimestamp">
                    <title>
                        <fmt:message key="dataCreazione" bundle="${i18n}"/>
                    </title>
                </field>
                <field sqlType="varchar" sqlLength="50" name="ACCOUNT_MOD" length="50" type="modifier"></field>
                <field sqlType="timestamp" sqlLength="7" name="DATE_MOD" type="modifierTimestamp">
                    <title>
                        <fmt:message key="dataModifica" bundle="${i18n}"/>
                    </title>
                </field>
            </fields>
        </DataSource>
        DATA_APPARTENENZA_SQ is the field with the isUnique validator.

        Comment


          #5
          We've now put in a fix for this which should be available in a nightly build in the next day or so.

          Regards,
          Isomorphic Software

          Comment


            #6
            SmartClient Version: v10.0p_2015-02-11/EVAL Deployment (expires 2015.04.12_08.43.44) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

            Hello, sorry for my late reply.

            Actually the other fields involved in the isUnique validator aren't submitted, so they're still null in the select query to check for uniqueness.

            This are the server logs:

            Code:
            2015-02-12 10:03:36,120 DEBUG RPCManager Processing 1 requests. 
            2015-02-12 10:03:36,120 DEBUG RPCManager Request #1 (DSRequest) payload: {
                criteria:{
                    ID_REC:90593
                },
                values:{
                    ID_REC:90593,
                    DATA_APPARTENENZA_SQ:new Date(1183240800000)
                },
                operationConfig:{
                    dataSource:"JAS_APPARTENENZA_SQUADRA",
                    repo:null,
                    operationType:"update",
                    textMatchStyle:"exact"
                },
                componentId:"gestGiocatoriStoricoAppSquadGrid",
                appID:"builtinApplication",
                operation:"JAS_APPARTENENZA_SQUADRA_update",
                oldValues:{
                    COGNOME_NOME:"UGO EDOARDO",
                    ID_REC:90593,
                    ID_GIOCATORE_FK:108,
                    DATE_MOD:new Date(1423731805000),
                    ACCOUNT_MOD:"cbosticco",
                    DATA_APPARTENENZA_SQ:new Date(1183327200000),
                    CREATOR:"cbosticco",
                    DATE_CREATOR:new Date(1423731805000),
                    ID_STAGIONE_FK:568110,
                    ID_SQUADRA_FK:781,
                    DATA_STAGIONE:new Date(1183240800000)
                }
            } 
            2015-02-12 10:03:36,121 INFO  IDACall Performing 1 operation(s) 
            2015-02-12 10:03:36,123 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] Performing fetch operation with
            	outputs: [ID_REC, DATA_APPARTENENZA_SQ]	criteria: {ID_GIOCATORE_FK:null,DATA_APPARTENENZA_SQ:new Date(1183240800000),ID_SQUADRA_FK:null}	values: {ID_GIOCATORE_FK:null,DATA_APPARTENENZA_SQ:new Date(1183240800000),ID_SQUADRA_FK:null} 
            2015-02-12 10:03:36,124 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause 
            2015-02-12 10:03:36,124 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] 1201: Executing SQL query on 'dbJas': SELECT JAS_APPARTENENZA_SQUADRA.ID_REC, JAS_APPARTENENZA_SQUADRA.DATA_APPARTENENZA_SQ FROM DBJAS.JAS_APPARTENENZA_SQUADRA WHERE (JAS_APPARTENENZA_SQUADRA.ID_GIOCATORE_FK IS NULL AND JAS_APPARTENENZA_SQUADRA.DATA_APPARTENENZA_SQ=TO_DATE('2007-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS') AND JAS_APPARTENENZA_SQUADRA.ID_SQUADRA_FK IS NULL) 
            2015-02-12 10:03:36,125 INFO  SQLDriver [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] Executing SQL query on 'dbJas': SELECT JAS_APPARTENENZA_SQUADRA.ID_REC, JAS_APPARTENENZA_SQUADRA.DATA_APPARTENENZA_SQ FROM DBJAS.JAS_APPARTENENZA_SQUADRA WHERE (JAS_APPARTENENZA_SQUADRA.ID_GIOCATORE_FK IS NULL AND JAS_APPARTENENZA_SQUADRA.DATA_APPARTENENZA_SQ=TO_DATE('2007-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS') AND JAS_APPARTENENZA_SQUADRA.ID_SQUADRA_FK IS NULL) 
            2015-02-12 10:03:36,128 INFO  DSResponse [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] DSResponse: List with 0 items 
            2015-02-12 10:03:36,129 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update] Performing update operation with
            	criteria: {ID_REC:90593}	values: {ID_REC:90593,DATA_APPARTENENZA_SQ:new Date(1183240800000),ACCOUNT_MOD:"cbosticco",DATE_MOD:new Date(1423731816122)} 
            2015-02-12 10:03:36,130 INFO  SQLDriver [builtinApplication.JAS_APPARTENENZA_SQUADRA_update] Executing SQL update on 'dbJas': UPDATE DBJAS.JAS_APPARTENENZA_SQUADRA SET ACCOUNT_MOD='cbosticco', DATA_APPARTENENZA_SQ=TO_DATE('2007-07-01 00:00:00','YYYY-MM-DD HH24:MI:SS'), DATE_MOD=TO_DATE('2015-02-12 10:03:36','YYYY-MM-DD HH24:MI:SS') WHERE (JAS_APPARTENENZA_SQUADRA.ID_REC=90593) 
            2015-02-12 10:03:36,134 DEBUG SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update] update operation affected 1 rows 
            2015-02-12 10:03:36,134 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update] primaryKeys: {ID_REC=90593} 
            2015-02-12 10:03:36,135 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] Performing fetch operation with
            	criteria: {ID_REC:90593}	values: {ID_REC:90593} 
            2015-02-12 10:03:36,136 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause AND $defaultJoinWhereClause 
            2015-02-12 10:03:36,137 INFO  SQLDataSource [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] 1201: Executing SQL query on 'dbJas': SELECT JAS_APPARTENENZA_SQUADRA.ID_REC, JAS_APPARTENENZA_SQUADRA.ID_STAGIONE_FK, JAS_APPARTENENZA_SQUADRA.ID_GIOCATORE_FK, JAS_APPARTENENZA_SQUADRA.ID_SQUADRA_FK, JAS_APPARTENENZA_SQUADRA.RUOLO, JAS_APPARTENENZA_SQUADRA.NUM_MAGLIA, JAS_APPARTENENZA_SQUADRA.NUM_MAGLIA_UEFA, JAS_APPARTENENZA_SQUADRA.DATA_APPARTENENZA_SQ, JAS_APPARTENENZA_SQUADRA.NOTE, JAS_APPARTENENZA_SQUADRA.CREATOR, JAS_APPARTENENZA_SQUADRA.DATE_CREATOR, JAS_APPARTENENZA_SQUADRA.ACCOUNT_MOD, JAS_APPARTENENZA_SQUADRA.DATE_MOD, JAS_SQUADRE.ID_CATEGORIA_FK AS CATEGORIA, JAS_ANAGRAFICA_GIOCATORI.COGNOME || ' ' || JAS_ANAGRAFICA_GIOCATORI.NOME AS COGNOME_NOME, JAS_STAGIONI.DATA_INIZIO AS DATA_STAGIONE FROM DBJAS.JAS_SQUADRE JAS_SQUADRE, DBJAS.JAS_APPARTENENZA_SQUADRA, DBJAS.JAS_ANAGRAFICA_GIOCATORI JAS_ANAGRAFICA_GIOCATORI, DBJAS.JAS_STAGIONI WHERE (JAS_APPARTENENZA_SQUADRA.ID_REC=90593) AND JAS_APPARTENENZA_SQUADRA.ID_SQUADRA_FK = JAS_SQUADRE.ID_REC AND JAS_APPARTENENZA_SQUADRA.ID_GIOCATORE_FK = JAS_ANAGRAFICA_GIOCATORI.ID_REC AND JAS_APPARTENENZA_SQUADRA.ID_STAGIONE_FK = JAS_STAGIONI.ID_REC 
            2015-02-12 10:03:36,137 INFO  SQLDriver [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] Executing SQL query on 'dbJas': SELECT JAS_APPARTENENZA_SQUADRA.ID_REC, JAS_APPARTENENZA_SQUADRA.ID_STAGIONE_FK, JAS_APPARTENENZA_SQUADRA.ID_GIOCATORE_FK, JAS_APPARTENENZA_SQUADRA.ID_SQUADRA_FK, JAS_APPARTENENZA_SQUADRA.RUOLO, JAS_APPARTENENZA_SQUADRA.NUM_MAGLIA, JAS_APPARTENENZA_SQUADRA.NUM_MAGLIA_UEFA, JAS_APPARTENENZA_SQUADRA.DATA_APPARTENENZA_SQ, JAS_APPARTENENZA_SQUADRA.NOTE, JAS_APPARTENENZA_SQUADRA.CREATOR, JAS_APPARTENENZA_SQUADRA.DATE_CREATOR, JAS_APPARTENENZA_SQUADRA.ACCOUNT_MOD, JAS_APPARTENENZA_SQUADRA.DATE_MOD, JAS_SQUADRE.ID_CATEGORIA_FK AS CATEGORIA, JAS_ANAGRAFICA_GIOCATORI.COGNOME || ' ' || JAS_ANAGRAFICA_GIOCATORI.NOME AS COGNOME_NOME, JAS_STAGIONI.DATA_INIZIO AS DATA_STAGIONE FROM DBJAS.JAS_SQUADRE JAS_SQUADRE, DBJAS.JAS_APPARTENENZA_SQUADRA, DBJAS.JAS_ANAGRAFICA_GIOCATORI JAS_ANAGRAFICA_GIOCATORI, DBJAS.JAS_STAGIONI WHERE (JAS_APPARTENENZA_SQUADRA.ID_REC=90593) AND JAS_APPARTENENZA_SQUADRA.ID_SQUADRA_FK = JAS_SQUADRE.ID_REC AND JAS_APPARTENENZA_SQUADRA.ID_GIOCATORE_FK = JAS_ANAGRAFICA_GIOCATORI.ID_REC AND JAS_APPARTENENZA_SQUADRA.ID_STAGIONE_FK = JAS_STAGIONI.ID_REC 
            2015-02-12 10:03:36,142 INFO  DSResponse [builtinApplication.JAS_APPARTENENZA_SQUADRA_update, builtinApplication.null] DSResponse: List with 1 items 
            2015-02-12 10:03:36,142 INFO  DSResponse [builtinApplication.JAS_APPARTENENZA_SQUADRA_update] DSResponse: List with 1 items 
            2015-02-12 10:03:36,142 DEBUG RPCManager Content type for RPC transaction: text/plain; charset=UTF-8 
            2015-02-12 10:03:36,145 DEBUG RPCManager non-DMI response, dropExtraFields: false 
            2015-02-12 10:03:36,153 DEBUG ExceptionTranslationFilter Chain processed normally 
            2015-02-12 10:03:36,154 DEBUG SecurityContextPersistenceFilter SecurityContextHolder now cleared, as request processing completed 
            2015-02-12 10:03:36,154 INFO  Compression /Jas/isomorphic/IDACall: 471 -> 323 bytes 
            2015-02-12 10:04:09,837 INFO  DefaultServicesManagerImpl Reloading registered services. 
            2015-02-12 10:04:09,837 DEBUG JpaTemplate Creating new EntityManager for JpaTemplate execution 
            2015-02-12 10:04:09,838 DEBUG SQL select registered0_.id as id0_, registered0_.allowedToProxy as allowedT2_0_, registered0_.anonymousAccess as anonymou3_0_, registered0_.description as descript4_0_, registered0_.enabled as enabled0_, registered0_.evaluation_order as evaluation6_0_, registered0_.ignoreAttributes as ignoreAt7_0_, registered0_.name as name0_, registered0_.serviceId as serviceId0_, registered0_.ssoEnabled as ssoEnabled0_, registered0_.theme as theme0_ from RegisteredServiceImpl registered0_ 
            Hibernate: select registered0_.id as id0_, registered0_.allowedToProxy as allowedT2_0_, registered0_.anonymousAccess as anonymou3_0_, registered0_.description as descript4_0_, registered0_.enabled as enabled0_, registered0_.evaluation_order as evaluation6_0_, registered0_.ignoreAttributes as ignoreAt7_0_, registered0_.name as name0_, registered0_.serviceId as serviceId0_, registered0_.ssoEnabled as ssoEnabled0_, registered0_.theme as theme0_ from RegisteredServiceImpl registered0_
            2015-02-12 10:04:09,843 DEBUG JpaTemplate Closing new EntityManager after JPA template execution 
            2015-02-12 10:04:09,843 DEBUG EntityManagerFactoryUtils Closing JPA EntityManager 
            2015-02-12 10:04:09,843 INFO  DefaultServicesManagerImpl Loaded 0 services.

            Comment


              #7
              It's not yet clear from the logs whether our fix also covers this case - have you tried with a new build, and if so, is this log from the new build?

              Comment


                #8
                Yes, the logs are from the latest build:
                SmartClient Version: v10.0p_2015-02-11/EVAL Deployment (expires 2015.04.12_08.43.44) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

                And the datasource involved are those of the previous post.

                Comment


                  #9
                  Apologies, it appears as though the fix was not back ported to the version you are using. This has now been done and should be available in a build in a couple of days.

                  Regards,
                  Isomorphic Software

                  Comment


                    #10
                    SmartClient Version: v10.0p_2015-04-09/Enterprise Development Only (built 2015-04-09)

                    Hello, sorry but it seems that the problem is still there.

                    Comment


                      #11
                      We've had a look through all the symptoms originally reported for this but we might have missed something. Therefore could you please provide an isolated test case which reproduces the issue?

                      Thanks,
                      Isomorphic Software

                      Comment


                        #12
                        Hello, actually the problem is that criteriaFields was written like this:
                        criteriaFields="ID_GIOCATORE_FK, DATA_APPARTENENZA_SQ, ID_STAGIONE_FK, ID_SQUADRA_FK"

                        removing the spaces after commas, like this:
                        criteriaFields="ID_GIOCATORE_FK,DATA_APPARTENENZA_SQ,ID_STAGIONE_FK,ID_SQUADRA_FK"

                        fixes the problem.
                        Isn't it supported to use spaces in those attributes with comma-separated values?

                        Anyway, thanks for the fix.

                        Comment


                          #13
                          Regarding the issue with the whitespaces in "criteriaFields", this was not a bug, but we added whitespace stripping anyway since it seems like a mistake people will make again.

                          Regards
                          Isomorphic Software

                          Comment

                          Working...
                          X