hibernate注解 @OrderBy

@OrderBy 用于实体中的集合的排序,指定排序字段,默认asc,可desc


例1:多对多映射

@ManyToMany(targetEntity = Menu.class,fetch = FetchType.LAZY)
@JoinTable(name="music_role_menu",joinColumns={@JoinColumn(name="role_id")},inverseJoinColumns={@JoinColumn(name="menu_id")})
@OrderBy("viewOrder")
private List menus;

例2:一对多映射

	@OneToMany(mappedBy = "showreel", fetch = FetchType.LAZY)
	@OrderBy("worksType desc")
	private List worksList;


你可能感兴趣的:(hibernate)