高质量语言。如何创建一个查询 returns 所有具有列表 <Point> 的行在日期之间

HQL. How to create a query that returns all the Lines with a List<Point> between dates

我有两个实体:线和点

@Entity
@Table(name = "line")
public class Line {
    private long id;
    private String name;

    @OneToMany
    @JoinColumn(name = "line_id")
    private List<Point> points;
}

@Entity
@Table(name = "point")
public class Point {
    @Id
    private long id;

    @Column(name = "x")
    private LocalDateTime x;

    @Column(name = "y")
    private int y;
}

select * from line;
+----+----------------------+
| id | name                 | 
+----+----------------------+
|  1 | lineA                |         
|  2 | lineB                |  
+----+----------------------+  

select * from point;
+----+--------------------------------------+----------+
| id |              x             |     y   |  line_id |
+----+-------------------------------------------------+
|  1 | 2016-01-01 02:00:00.000000 |     1   |      1   |
|  2 | 2017-01-01 02:00:00.000000 |     2   |      1   |
|  3 | 2018-01-11 02:00:00.000000 |     1   |      1   |
|  4 | 2019-01-01 02:00:00.000000 |     3   |      1   |
|  5 | 2015-01-01 02:00:00.000000 |     2   |      2   |
|  6 | 2016-01-01 02:00:00.000000 |     1   |      2   |
|  7 | 2017-01-01 02:00:00.000000 |     3   |      2   |
|  8 | 2018-01-01 02:00:00.000000 |     2   |      2   |
+----+----------------------------+---------+----------+

HQL 查询应该是什么样子才能return包含两个日期之间的点的所有行 (List) 的列表?

entityManager.createQuery("select distinct l from Line l join l.points p where p.x between :sd and :ed)").setParameter("sd", LocalDateTime.of(2017, 1, 1, 0, 0)).setParameter("ed", LocalDateTime.of(2018, 1, 1, 0, 0)).getResultList()

这样的请求将 return 至少有一个点位于日期间隔内的行。在这种情况下,该线将包含它拥有的所有点。但是我需要 return 所有只包含这两个日期之间的点的行。

我想这很简单。但是由于我是hql的新手,在sql中,我不知道该怎么做。

目前通过拆分成单独的请求来解决。首先,所有的线都得到,只有这样,每条线的点都得到