英文:
JPA / Hibernate - @OrderBy random
问题
我有一个JpaRepository类和具有OneToMany单向关系的实体。我尝试使用@OrderBy注解,但它没有起作用。我需要列表项以随机顺序排列。
@Entity
public class Foo {
@OneToMany
@JoinColumn(name = "foo_id")
@OrderBy("function('RAND')")
private List<Bar> bars;
}
英文:
I have JpaRepository class and entities with OneToMany unidirectional relationship. I tried to use the @OrderBy annotation but it didn't work. I need the list items to be in random order.
@Entity
public class Foo {
@OneToMany
@JoinColumn(name = "foo_id")
@OrderBy("function('RAND')")
private List<Bar> bars;
}
</details>
专注分享java语言的经验与见解,让所有开发者获益!
评论