I have entities:
@Entity
public class C {
@Column
private String name;
}
@Entity
public class B {
@Column
private Integer id;
@ManyToOne
@JoinColumn(name = "id_c")
private C c;
}
@Entity
public class A {
@OneToMany(mappedBy = "a")
@OrderBy("id")
private Set<B> itemsB;
}
Now when i access to A.itemsB() - items ordered by B.id
I need to get A.itemsB() ordered by C.name. Is this possible?
I tried to write something like @OrderBy("c.name") but it not work.
只需检查导入的 Order : org.hibernate.annotations.OrderBy 或 javax.persistence.OrderBy .. 你应该使用第二个。
您不应使用“Set<B>”,而应使用“List<B>”。集合始终是无序的。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.