我有三个关系UserDetails
hasmanyFiledTask
和Task
hasMany的实体FiledTask
。我想要的只是FiledTask
特定的列表User
对于用户详细信息:
@OneToMany(mappedBy="user",cascade=CascadeType.ALL)
Collection<FiledTask> filedTasks = new ArrayList<FiledTask>();
对于我有的任务
@OneToMany(mappedBy="task")
Collection<FiledTask> filedTasks = new ArrayList<FiledTask>();
FiledTask 看起来像
@ManyToOne
@JoinColumn(nullable = false, name = "taskId")
private Tasks task;
@ManyToOne
@JoinColumn(nullable = false, name = "userId")
private UserDetails user;
我试过了
query = session.createQuery("from Tasks as tasks inner join tasks.filedTasks as files with files.user = :user");
query.setParameter("user", user); //user is UserDetails instance
但是我得到错误子句只能引用驱动表中的列,意味着 FiledTask 不能 userId 进行比较?
with clause can only reference columns in the driving table [from com.akhi.app.cdm.Tasks as tasks inner join tasks.filedTasks as files with files.user = :user]