我的数据库:
WorkflowProcess
id | name
WorkflowProcessToWorkflowProcess
ancestor | descendent
我需要查询 root WorkflowProcess
。有了这个表结构,我正在寻找类似的查询SELECT * FROM WorkflowProcess WHERE id NOT IN (SELECT DISTINCT descendent FROM WorkflowProcessToWorkflowProcess)
我的WorkflowProcess
实体:
private Collection<WorkflowProcessEntity> workflowProcesses;
@JoinTable(name = "Workflow_Process_to_Workflow_Process", joinColumns = {
@JoinColumn(name = "ancestor", referencedColumnName = "id")}, inverseJoinColumns = {
@JoinColumn(name = "descendent", referencedColumnName = "id")})
@ManyToMany()
public Collection<WorkflowProcessEntity> getWorkflowProcesses() {
return workflowProcesses;
}
public void setWorkflowProcesses(Collection<WorkflowProcessEntity> workflowProcesses) {
this.workflowProcesses = workflowProcesses;
}
是否可以使用 HQL 来完成此任务?