title: Sorting int field of the wrapper class spring
body: <p>I have a Navigation class where I am dynamically creating the navigation I am having two tables folder(it is directory that contains files) and content(it is like files or pages that will render the content on the public site). I have created a Navigation class in which I am having a wrapper class for merging the fields of content into the folder. I have tried using @OrderBy and @OrderColumn but I came to know that it will only work with collections. </p>
  
  <p><code>List&lt;Folder&gt; folder = folderRepository.findAllByNavDepthLessThanOrderByNavDepthAsc(3);</code></p>
  
  <p>here I am sorting it with navDepth(this column belongs to Folder entity) I also want to sort it with navOrder(this column belongs to Content entity)</p>
  
  <pre><code>@Service
  public class NavigationService {
  
      @Qualifier("jdbcMySQL")
      private JdbcTemplate jdbcTemplate;
      private FolderRepository folderRepository;
      private FolderService folderService;
  
      @Autowired
      public NavigationService(JdbcTemplate jdbcTemplate, 
              FolderRepository folderRepository,
              FolderService folderService) {
          this.jdbcTemplate = jdbcTemplate;
          this.folderRepository = folderRepository;
          this.folderService = folderService;
      }
  
      @Transactional(propagation=Propagation.REQUIRED, readOnly=false)
      public Map&lt;String, NavigationItem&gt; navigationItems() {
          // TODO: // CROSS cutting AOP springs
          // TODO: http://docs.spring.io/spring/docs/4.2.0.BUILD-SNAPSHOT/spring-framework-reference/htmlsingle/#aop
          List&lt;Folder&gt; folder = folderRepository.findAllByNavDepthLessThanOrderByNavDepthAsc(3);
          // List&lt;Folder&gt; folder = folderService.navigation();
          Map&lt;String, NavigationItem&gt; navItems = new LinkedHashMap&lt;String, NavigationService.NavigationItem&gt;();
          for (int i = 0; i &lt; folder.size(); i++) {
              NavigationItem ni = new NavigationItem();
              ni.setNavDepth((int) (folder.get(i).getNavDepth()));
              ni.setFileNamePath(folder.get(i).getDirectoryPath());
              ni.setFilepath(folder.get(i).getDirectoryPath());
              ni.setChildren(folder.get(i).getContent());
              for (int k = 0; k &lt; folder.size(); k++) {
                  if(folder.get(i).getId() == folder.get(k).getParentId()) {
                          ni.addSubFolder(folder.get(k));
                          System.out.println(folder.get(i).getTitle());
                          System.out.println(folder.get(k));
                          System.out.println("---!!!!!!________----------!!!!!!!!");
                  }
              }
              navItems.put(folder.get(i).getTitle(), ni);
          }
          return navItems;
      }
  
      public class NavigationItem {
          private long id;
          private long parentId;
          private String title;
          private String fileName;
          private String fileNamePath;
          private int navDepth;
          private int navOrder;
          private String parentFileName;
          private String filePath;
          private String folderName;
          @OrderColumn(name="navOrder ASC")
          private List&lt;Content&gt; children = new ArrayList();
          private ArrayList&lt;Folder&gt; subFolder = new ArrayList();
  
  
          public void setSubFolder(ArrayList&lt;Folder&gt; subFolder) {
              this.subFolder = subFolder;
          }
          public String getFilePath() {
              return filePath;
          }
          public void setFilePath(String filePath) {
              this.filePath = filePath;
          }
          public String getFolderName() {
              return folderName;
          }
          public void setFolderName(String folderName) {
              this.folderName = folderName;
          }
          public ArrayList&lt;Folder&gt; getSubFolder() {
              return subFolder;
          }
          public void addSubFolder(Folder subFolder) {
              this.subFolder.add(subFolder);
          }
          public void setChildren(List&lt;Content&gt; list) {
              this.children = list;
          }
          public long getId() {
              return id;
          }
          public void setId(long id) {
              this.id = id;
          }
          public long getParentId() {
              return parentId;
          }
          public void setParentId(long parentId) {
              this.parentId = parentId;
          }
          public String getTitle() {
              return title;
          }
          public void setTitle(String title) {
              this.title = title;
          }
          public String getFileName() {
              return fileName;
          }
          public void setFileName(String fileName) {
              this.fileName = fileName;
          }
          public String getFileNamePath() {
              return fileNamePath;
          }
          public void setFileNamePath(String fileNamePath) {
              this.fileNamePath = fileNamePath;
          }
          public long getNavDepth() {
              return navDepth;
          }
          public void setNavDepth(int navDepth) {
              this.navDepth = navDepth;
          }
          public long getNavOrder() {
              return navOrder;
          }
          public void setNavOrder(int navOrder) {
              this.navOrder = navOrder;
          }
          public String getParentFileName() {
              return parentFileName;
          }
          public void setParentFileName(String parentFileName) {
              this.parentFileName = parentFileName;
          }
          public List&lt;Content&gt; getChildren() {
              return children;
          }
          public void addChild(Content child) {
              children.add(child);
          }
          public String getFilepath() {
              return filePath;
          }
          public void setFilepath(String filePath) {
              this.filePath = filePath;
          }
  
      }
  }
  </code></pre>