Bonjour,
Je souhaite que ma requette me retourne une liste ordonnéemais ce n'est pas le cas.
controlleur
Code :Sélectionner tout -Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
List<Menu> menus = menuService.findByRole(role_id);
    	    for (Menu menu : menus) {
    	    	System.out.println("w " + menu.toString());
    	    	List<Menu> fils = menu.getMenus().stream().collect(Collectors.toList());
    	    	for (Menu m : menu.getMenus().stream().collect(Collectors.toList())) {
    	    		System.out.println("menu: " + menu.toString() + "  sous menu: " + m.toString() );
    	    	}
            }

Mapper
Code :Sélectionner tout -Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 @Select("Select #{role} role,id,name,parentId,action,displayed,ordered From Menu Where parentId = #{id} and displayed is true and id in (select menu from menu_role where role in (1,#{role})) order by ordered asc")
    @Results(value = {
	      @Result(property = "id", column = "id"),
	      @Result(property = "name", column = "name"),
	      @Result(property = "action", column = "action"),
	      @Result(property = "displayed", column = "displayed"),
	      @Result(property = "ordered", column = "ordered"),
	      //@Result(property = "menu", javaType = com.laplace.mvc.model.Menu.class, column = "parentId",one=@One(select = "MenuMapper.findById")),
  	      @Result(property = "menu", javaType = com.laplace.mvc.model.Menu.class, column = "parentId",one=@One(select = "findById")),
          @Result(property = "menus", javaType = Set.class, column="{id=id,role=role}", many=@Many(select = "findByParentByRole")) //{id=id,TypeRole=TypeRole}
    })
    public Menu findByParentByRole(int id,int role);      
    
    @Select("Select #{role} role,id,name,parentId,action,displayed,ordered From Menu Where parentId is null and displayed is true and id in (select menu from menu_role where role in (1,#{role})) order by ordered asc")
    @Results(value = {
    	      @Result(property = "id", column = "id"),
      	      @Result(property = "name", column = "name"),
      	      @Result(property = "action", column = "action"),
      	      @Result(property = "displayed", column = "displayed"),
      	      @Result(property = "ordered", column = "ordered"),
    	      //@Result(property = "menu", javaType = com.laplace.mvc.model.Menu.class, column = "parentId",one=@One(select = "MenuMapper.findById")),
      	      @Result(property = "menu", javaType = com.laplace.mvc.model.Menu.class, column = "parentId",one=@One(select = "findById")),
              @Result(property = "menus", javaType = Set.class, column="{id=id,role=role}", many=@Many(select = "findByParentByRole"))//{id=id,TypeRole=TypeRole}
    })
    public List<Menu> findByRole(int role);


a l'execution la liste n'est pas ordonnée par ordered

menu: Menu : [ 1, Session, null, true, [] ] sous menu: Menu : [ 5, Gestion Utilisateur, null, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] sous menu: Menu : [ 3, Modification de Mot de Passe, users/updateMP, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] sous menu: Menu : [ 2, Reconnexion, logout, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] sous menu: Menu : [ 4, Messagerie, msgerie, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] sous menu: Menu : [ 10, Quitter, null, true, [] ]
j'aurais souhaité avoir selon l'ordre
menu: Menu : [ 1, Session, null, true, [] ] fils: Menu : [ 2, Reconnexion, logout, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] fils: Menu : [ 3, Modification de Mot de Passe, users/updateMP, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] fils: Menu : [ 4, Messagerie, msgerie, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] fils: Menu : [ 5, Gestion Utilisateur, null, true, [] ]
menu: Menu : [ 1, Session, null, true, [] ] fils: Menu : [ 10, Quitter, null, true, [] ]
merci bien