Spring Data Jpa使用ManyToMany关系时的生成查询

时间:2017-06-05 09:19:54

标签: spring hibernate jpa

如何在jpa查询中编写sql查询.....

select s.skill_name from K_ACTIVITI_POC.review r,  K_ACTIVITI_POC.task t ,K_ACTIVITI_POC.task_skill ts,  K_ACTIVITI_POC.skills s 
where r.rev_id = t.rev_id 
and t.task_id = ts.task_id
and s.skill_id= ts.skill_id
and r.rev_id =1
and t.task_id=1;

下面有java代码..........

public interface SkillRepository extends CrudRepository<Skill, Long> {

    @Query("select s.skill_name from Review r Skill s INNER JOIN USER_SKILL ON s.skillId=sb.skillId INNER JOIN Task t ON t.taskId=sb.taskId where r.revId =:revId and t.task_id=:taskId;")
    public List<Skill> findByAllSkills(@Param("revId") Long revId, @Param("taskId")Long taskId);

}

0 个答案:

没有答案