title: How to get Entity's object information by Spring Rest and Angularjs?
body: <p>I have a request handler method "listAll" which returns all articles. When I invoke this method it returns Article list but When I access this return in angularjs side it does not contain User info forexample article.user.name does not return any info, but I can acces the other article fields. My entities, angularjs script and controller is below. Thanks for your helps</p>
  
  <pre><code>@Entity
  public class Article {
  
      @Id
      @GeneratedValue
      private int id;
      private String title;
      private String summary;
      private String description;
      private String createdDate;
  
      @ManyToOne
      private User user;
  
      public Article(){
  
      }
  
      public Article(String title, String summary, String description, String createdDate, int id, User user) {
          super();
          this.title= title;
          this.summary= summary;
          this.description = description;
          this.createdDate = createdDate;
          this.user = user;
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getTitle() {
          return title;
      }
      public void setTitle(String title) {
          this.title = title;
      }
  
      public String getSummary() {
          return summary;
      }
      public void setSummary(String summary) {
          this.summary = summary;
      }
  
      public String getDescription() {
          return description;
      }
      public void setDescription(String description) {
          this.description = description;
      }
  
      public String getCreatedDate() {
          return createdDate;
      }
      public void setCreatedDate(String createdDate) {
          this.createdDate = createdDate;
      }
  
      @JsonBackReference
      public User getUser() {
          return user;
      }
  
      public void setUser(User user) {
          this.user = user;
      }
  
      @Override
      public boolean equals(Object object) {
          if (object instanceof Article){
              Article article = (Article) object;
              return article.id == id;
          }
  
          return false;
      }
  
      @Override
      public int hashCode() {
          return id;
      }
  }
  
  
  @Entity
  @Table(name = "system_user")
  public class User {
  
      @Id
      @GeneratedValue
      private int id;
  
      private String email;
      private String name;
      private String enabled;
      private String password;
  
      @Enumerated(EnumType.STRING)
      @Column(name = "user_role")
      private Role role;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Role getRole() {
          return role;
      }
  
      public void setRole(Role role) {
          this.role = role;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getEnabled() {
          return enabled;
      }
  
      public void setEnabled(String enabled) {
          this.enabled = enabled;
      }
  }
  </code></pre>
  
  <p>Request Handler method:</p>
  
  <pre><code>  @RequestMapping(method = RequestMethod.GET, produces = "application/json")
      public ResponseEntity&lt;?&gt; listAll(@RequestParam int page, Locale locale) {
          return createListAllResponse(page, locale);
      }
  </code></pre>
  
  <p>Angularjs script:</p>
  
  <p>it returns "data.articles[i].user" is undefined in following script:</p>
  
  <pre><code>$scope.populateTable = function (data) {
          if (data.pagesCount &gt; 0) {
              $scope.state = 'list';
              $scope.page = {source: data.articles, currentPage: $scope.pageToGet, pagesCount: data.pagesCount, totalArticles : data.totalArticles};
              alert("data.articles.length: " + data.articles.length)
              for (var i = 0; i &lt; data.articles.length; i++) {
                  alert("data.articles ["+i+"]: "+ data.articles[i].user.name);
              }
  
              if($scope.page.pagesCount &lt;= $scope.page.currentPage){
                  $scope.pageToGet = $scope.page.pagesCount - 1;
                  $scope.page.currentPage = $scope.page.pagesCount - 1;
              }
  
              $scope.displayCreateArticleButton = true;
              $scope.displaySearchButton = true;
          } else {
              $scope.state = 'noresult';
              $scope.displayCreateArticleButton = true;
  
              if(!$scope.searchFor){
                  $scope.displaySearchButton = false;
              }
          }
  
          if (data.actionMessage || data.searchMessage) {
              $scope.displayMessageToUser = $scope.lastAction != 'search';
  
              $scope.page.actionMessage = data.actionMessage;
              $scope.page.searchMessage = data.searchMessage;
          } else {
              $scope.displayMessageToUser = false;
          }
      }
  </code></pre>