Reputation: 7852
I try implement @OrderBy
hibernate annotation, but get error 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 entity extend match class with start
field:
...
@Entity
@Table(name="matches")
public class DbMatch extends Match{
...
Match class and start
field:
...
@MappedSuperclass
public class Match {
@Column(columnDefinition="DATETIME")
@JsonSerialize(using=JsonDateSerializer.class)
@JsonView(Views.Public.class)
private Date start;
...
Upvotes: 1
Views: 324
Reputation: 9022
It seems you are using org.hibernate.annotations.OrderBy
which expects an SQL clause.
You should use javax.persistence.OrderBy
instead, which expects a property name:
@Entity
@Table(name ="algo")
public class Algo{
...
@ManyToMany(fetch = FetchType.LAZY )
@OrderBy("start")
protected List<DbMatch> matches = new ArrayList<DbMatch>();
Upvotes: 2