5 Replies Latest reply on Jun 3, 2010 8:52 AM by serkan.s.eskici.online.nl

    Seam Remoting not returning deep object tree

    rituraj_tiwari

      I have an entity represent a hierarchical structure, like a file system, like:


      @Entity
      Class File
      {
          public String getName() { ... }
          public List<File> getChildren() { ... }
      }
      
      



      Now, I have a web remote method on my SLSB Seam component that returns a collection these File entities:



      @WebRemote public List<File> getFiles();



      What I am discovering looking at the Seam remote debug window is that the list of File objects is being returned, but those File objects don't have any children. When I view the returned objects on the server side they have all children as expected.


      Is a deep object hierarchy not supported in Seam remoting?


      Thanks.


      -Raj

        • 1. Re: Seam Remoting not returning deep object tree
          shane.bryzak

          It should definitely support this -  could you please raise this as an issue in JIRA with a reproducible test case?

          • 2. Re: Seam Remoting not returning deep object tree
            rituraj_tiwari

            Shane,
            Thanks for your response. A simple test case I wrote works. Right now I am looking to see why my actual code fails.


            -Raj

            • 3. Re: Seam Remoting not returning deep object tree
              rituraj_tiwari

              Shane,
              This is looking like a concurrency issue. My actual code makes several remoting calls in quick succession. I set breakpoints in MarshalUtils to see what was coming back from remoting calls. The result value returned by call.getResult() looks different depending on the timing of my pause and resume of the threads.


              Let me know if this info is sufficient for a JIRA bug report.


              -Raj

              • 4. Re: Seam Remoting not returning deep object tree
                rituraj_tiwari

                Shane,
                Looks like this was an issue with loading my entities. Seam remoting is working fine.


                Thanks for your time.


                -Raj

                • 5. Re: Seam Remoting not returning deep object tree
                  serkan.s.eskici.online.nl

                  Can you pls provide some feedback on how you've solved this problem ?


                  Because I'm having the same problem now.


                  I have this code:



                  @Entity
                  public class Customer {
                  
                    //some primitive attributes
                    ...
                    
                    @Embedded @NotNull  
                    private Address address = new Address();
                  }
                  





                  @Name("myRemoteBean")
                  public class RemoteBean {
                  
                    @In EntityManager em;
                  
                    @WebRemote
                    public List<Customer> getCustomers() {
                         return this.em.createQuery("from Customer").getResultList();
                    }
                  }
                  




                  <ui:define name="body">
                      <s:remote include="gmapViewer"/>
                      
                      <div id="map" style="width: 450px; height: 450px;"></div>
                      
                      <button id="contactsBtn">Show customers</button>
                  </ui:define>
                  



                  /**
                   * Seam Remote call.
                   * 
                   * @return a list of customer addresses.
                   */
                  function getContacts() {
                       Seam.Remoting.setDebug(false);
                       Seam.Component.getInstance("myRemoteBean").getCustomers(callback);
                  }
                  
                  /**
                   * Seam Remote call result.
                   * 
                   * @param result the result of the call
                   */
                  function callback(result) {
                       for(var i=0; i<result.length; i++) {
                            var customer = result[i];
                                  alert("firstname: " + customer.getFirstname());   <------------------- this works fine !
                            alert("street: " + customer.getAddress().getStreet()); <-------------- this is not working !
                       }
                  }
                  



                  And when I change my code to this:


                    @WebRemote
                    public List<Address> getCustomers() {
                         return this.em.createQuery("select c.address from Customer c").getResultList();
                    }
                  



                  Then it works !!


                  It seems that I can't iterate deep through the object graph.