java - 加入单向关联

标签 java jpa querydsl

SchoolStudent 之间的关联是单向的。如何使用 JPA 标准或 Querydsl 从 Student 创建查询并加入 School

class School{
    @OneToMany
    private List<Student> students;
}
class Student{
    private String name
}

最佳答案

您不能直接从学生加入到学校,但可以这样做

query.from(school, student).where(student.in(school.students))

关于java - 加入单向关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28762407/

相关文章:

java - JPA + Hibernate + Spring - 父子持久化生成 ID 导致外键错误

java - #Resolved - 查询//存储函数调用中不存在位置参数

java - 使用 querydsl 如何检查由一对多关系产生的一组对象中的特定对象?

java - maven:如何在 .jar 中包含注释生成的 .java 文件

scala - 电梯的 ORM : Mapper or JPA?

java - 特定类型会影响 ArrayList 的性能吗?

elasticsearch - 使用 doc_count 作为累计计数

java - QueryDSL-maven-您需要使用 JDK 运行构建或在类路径上有 tools.jar

java - UnexpectedRollbackException - 完整的场景分析

java - mustache -Java : How to get value in Map by key