我正在使用带有PostgreSQL数据库的hibernate。我有两个实体bean Task和User。
@Entity
@Table(schema = TaskConstants.TASKSCHEMA, name = "tasks")
public class Task {
@Id
@Column(name = "id", columnDefinition = "serial")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "title")
private String title;
@Column(name="assigned_to")
private int assignedTo;
@ManyToOne(targetEntity = User.class, fetch = FetchType.EAGER)
@JoinColumn(name = "assigned_to", referencedColumnName = "id", insertable = false, updatable = false)
private User assignedPerson;
}
@Entity
@Table(schema = TaskConstants.TASKSCHEMA, name = "users")
public class User {
@Id
@Column(name = "id", columnDefinition = "serial")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "full_name")
private String fullName;
}
我需要使用单个hql查询按用户的全名对任务进行排序。有人请帮忙。
答案 0 :(得分:0)