我尝试实现@OrderBy
hibernate注释,但得到错误Unknown column 'matches0_.start' in 'order clause'
。
...
@Entity
@Table(name ="algo")
public class Algo{
...
@JsonView(Views.Internal.class)
@ManyToMany(fetch = FetchType.LAZY )
@OrderBy(clause = "start") // want order list by start
protected List<DbMatch> matches = new ArrayList<DbMatch>();
...
DbMatch实体使用start
字段扩展匹配类:
...
@Entity
@Table(name="matches")
public class DbMatch extends Match{
...
匹配课程和start
字段:
...
@MappedSuperclass
public class Match {
@Column(columnDefinition="DATETIME")
@JsonSerialize(using=JsonDateSerializer.class)
@JsonView(Views.Public.class)
private Date start;
...
答案 0 :(得分:2)
您似乎正在使用需要 SQL子句的org.hibernate.annotations.OrderBy
。
您应该使用javax.persistence.OrderBy
代替,它需要一个属性名称:
@Entity
@Table(name ="algo")
public class Algo{
...
@ManyToMany(fetch = FetchType.LAZY )
@OrderBy("start")
protected List<DbMatch> matches = new ArrayList<DbMatch>();