我试图在updatedOn字段的基础上对员工类的记录进行排序。 UpdatedOn字段位于ChangeInfo类中,它是员工类的嵌入类。我是用apache deltaspike做的。
示例:
标准crtieria = findEmployees(); criteria.join(Employee_.changeInfo,其中(ChangeInfo.class).orderDesc(ChangeInfo_.updatedOn));
当我使用上面的代码时,我不会在最终查询中附加一个order by子句。
@Entity
@Table(name = "employee")
public class Employee
{
@Id
@Column(name = "id", unique = true, nullable = false, precision = 9)
private Long id ;
@Column(name = "name")
private String name;
@Column(name = "designation")
private String designation;
@Embedded
private ChangeInfo changeInfo;
}
public class ChangeInfo {
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_on")
private Date updatedOn;
@Column(name = "updatedBy")
private String updatedBy;
}