I have an entity User and System
@Entity
public class User {
private Long id;
private String name;
}
@Entity
public class System{
private Long id;
private Long SystemId;
@ManyToMany
private Set<User> users;
}
and one table created by hibernate legalhold_system
I want to get all the user related to System ID, I can fetch the same using below native query
select * from user where id in (select user_id from legalhold_system where system_id in(select id from system_user where system_id=:1))
How can I achieve the same with Spring JPA query, As I don't have legalhold_system entity present in Code?
如果只有这两个实体,则可以使用以下查询来实现:
SELECT s.users FROM System s WHERE s.systemId = :systemId
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.