Announcement

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

    DSResponse.data as String in dynamicForm.saveData() return.

    I'd like to get the id of a new record inserted in the database from a dynamicForm, the saveData() method inserts it with success but somehow the data prop in the callback is a String and not a object.

    addNewDynamicForm.saveData(function (dsResponse, data, dsRequest) {
    var id = data.id; // this is undefined
    });

    here is the String inside data:

    "//isc_RPCResponseStart-->[{affectedRows:1,data:{modifiedUser:30,createdUser:30,created:new Date(1466133145985),companyNonLocked:true,version:0,deleted:false,name:"test",modified:new Date(1466133145985),id:32},invalidateCache:false,isDSResponse:true,operationType:"add",queueStatus:0isc.logWarn("java.lang.OutOfMemoryError: Java heap space\n\tat java.util.Arrays.copyOf(Arrays.java:3332)\n\tat java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:137)\n\tat java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:121)\n\tat java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:421)\n\tat java.lang.StringBuffer.append(StringBuffer.java:272)\n\tat java.io.StringWriter.write(StringWriter.java:101)\n\tat com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1294)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:842)\n\tat com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1409)\n\tat com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1358)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:790)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:703)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:694)\n\tat com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1245)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:842)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:703)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:694)\n\tat com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1245)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:842)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:703)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:694)\n\tat com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1245)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:842)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:703)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:694)\n\tat com.isomorphic.js.JSTranslater.convertMap(JSTranslater.java:1245)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:788)\n\tat com.isomorphic.js.JSTranslater.convertIterator(JSTranslater.java:1409)\n\tat com.isomorphic.js.JSTranslater.convertCollection(JSTranslater.java:1358)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:790)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:703)\n\tat com.isomorphic.js.JSTranslater.convert(JSTranslater.java:694)\n");"

    #2
    Did you read the error message? You have an Out of Memory error. This might be due to returning a looping data structure (self-referencing) in your DSResponse, which is not automatically handled.

    Comment


      #3
      Thank you, I think that OutOfMemory error is due to another thing, my Bean doesn't have a reference to itself:

      <DataSource ID="AdminCompanyHbmDS" serverType="hibernate"
      beanClassName="com.wazollc.alphatheory.hibernate.bo.CompanyBO"
      schemaBean="com.wazollc.alphatheory.hibernate.bo.CompanyBO"
      dropExtraFields="true">

      public class CompanyBO implements java.io.Serializable {


      private Long id;
      private Long version;
      private String name;
      private Date created;
      private Date modified;
      private Boolean require2FactorAuth;
      private Boolean companyNonLocked;
      private ATUserBO createdUser;
      private ATUserBO modifiedUser;
      private PasswordPolicyBO passwordPolicy;
      private Boolean deleted;
      private Address companyAddress;

      public CompanyBO() {
      }

      But maybe these 2:

      private ATUserBO createdUser;
      private ATUserBO modifiedUser;

      They have references to themselves, maybe them are causing this? it shouldn't, it isn't creating these fields, it should only make a reference.

      The weird thing is that my Server Log tab in the debug console isn't enabled even I having a Smartclient license so I can't debug it more.

      But if it was a self-reference problem, what is the recommended action to take to solve this?

      thank you.

      Last edited by ccarneiro; 17 Jun 2016, 04:22.

      Comment


        #4
        After trying to understand this issue even more, I think the problem is with the select it does after the insert. The data is inserted with no problem but when it tries to select the inserted data to return, it isn't respecting the dropExtraFields="true" and it is trying to populate the problematic fields.

        I tried adding canSave="false" to the probably problematic fields or adding this in a DMI operation:

        dsRequest = dsRequest.removeField("modifiedUser", false);
        dsRequest = dsRequest.removeField("createdUser", false);

        But if I do this, it exclude those fields from the insert and it doesn't work because it is a not-null column in the database.

        I also tried set this in the DMI:

        dsRequest.setGenerateRelatedUpdates(false);

        But it won't work at all with hibernate add because the hibernateDatasourceClass has this method that will always return true and try to resolve the relations:

        public boolean handlesRelations() {
        return true;
        }

        How do I skip the processing relations for a add method? Any idea?
        Last edited by ccarneiro; 17 Jun 2016, 07:28.

        Comment


          #5
          Finally I understood that the problem is about the DSResponse and not with the DSRequest, so this ugly tweak fixed the issue for now:

          public DSResponse addNewCompany(DSRequest dsRequest) throws Exception {

          DSResponse response = dsRequest.execute();
          DSResponse newResponse = new DSResponse(response.getDataSource(), response.getData()); // this will discard the relatedUpdates and won't break the UI

          return newResponse;
          }

          I created a new DSResponse ignoring the relatedUpdates in the original DSResponse.

          But is there a more elegant way to do this? you told that self-referencing in DSResponse structure isn't automatically handled, so what is the recommended way to work with this? I searched in the documentation but I haven't found anything.

          thank you.

          Comment


            #6
            We are working on this, but in order to fix it we must clearly see the problem, however after several attempts this is still not reproduced.

            Could you please provide more information? This could include complete definitions of all fields (or complete datasources) directly or indirectly participating in the add operation, plus any other information you imagine could help.

            Also, could you please tell us what exact Smartclient version you are using? And just in case if you are using older build, please check if your issue is still there with the latest build of the version you are using.

            Comment


              #7
              Thank you,

              I just had a structure like this:

              Company
              *-------- modifiedUser (User)
              *--------------- modifiedUser (user)

              A company has a modifiedUser that will keep a log of the latest user that changed something and inside that user it has a modified user again. So as we already know, for these cases working with datasource="hibernate", we need to keep it with dropExtraFields="true" to prevent infinite loop, the fetch does work well, but when I try to do an update, the update occurs well but because the relatedUpdates it tries to lookup the changed data and doesn't respect the dropExtraFields="true, then I had to create a new DSResponse with a DMI operation to discard the relatedUpdates:

              DSResponse response = dsRequest.execute();
              DSResponse newResponse = new DSResponse(response.getDataSource(), response.getData()); // this will discard the relatedUpdates and won't break the UI

              return newResponse;
              }

              I can try to build a sample with this issue if you can't reproduce.
              About the iso version, yes it happens in the last version.

              Thanks.

              Comment


                #8
                You still did not tell us what exactly version you are using, is it 5.0p, 5.1p, 6.0p or 6.1d?

                We are in the process of making changes to respect dropExtraFields setting on nested objects, which will fix your issue with populating "extra" fields leading to self-reference loops.

                Despite that it would be great if you could showcase the issue in a standalone use case. The point is, that we do have a failsafe to prevent out-of-memory problem and it is weird that it doesn't work for you. Note that you should *not* hit out-of-memory exception even if your datasources creating infinite loops specify dropExtraFields=false. So we are very curious what's going on.

                Thank you!

                Comment

                Working...
                X