HQL 子查询查询选择

发布于 2024-12-04 07:12:38 字数 662 浏览 0 评论 0原文

当我执行此查询时,我总是收到错误太多列

SELECT o FROM Overlay o WHERE ( :coordinate ) IN ELEMENTS(o.blocksCoordinates)

如果我在 sql 中执行此操作,它会起作用:

Select * from Overlay overlay0_ where (0,0) in (select x, y from ...

坐标是一个带有 x 和 y 值的简单嵌入实体。

@ElementCollection
private Set<Coordinate> blocksCoordinates = new HashSet<Coordinate>();

我的坐标实体:

@Embeddable
public class Coordinate implements Serializable {
    private static final long serialVersionUID = -5866341829302555966L;

    protected int x;
    protected int y;

我做错了什么?

I always get the error too many Columns when i execute this query.

SELECT o FROM Overlay o WHERE ( :coordinate ) IN ELEMENTS(o.blocksCoordinates)

If i do it in sql it works:

Select * from Overlay overlay0_ where (0,0) in (select x, y from ...

Coordinate is a simple embedded entity with an x and y value.

@ElementCollection
private Set<Coordinate> blocksCoordinates = new HashSet<Coordinate>();

My Coordinate entity:

@Embeddable
public class Coordinate implements Serializable {
    private static final long serialVersionUID = -5866341829302555966L;

    protected int x;
    protected int y;

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神经暖 2024-12-11 07:12:38

尝试相反的方式:

select o from Overlay o left outer join o.blocksCoordinates as c where c = :coordinate

或者使用 with 关键字:

select o from Overlay o join o.blocksCoordinates as c with c = :coordinate

使用该查询应该返回 c = 坐标上的连接成功的任何 Overlay。

编辑:或者,尝试使用 x 和 y 值:

select o from Overlay o join o.blocksCoordinates as c with c.x = :x and c.y = :y

Try it the other way round:

select o from Overlay o left outer join o.blocksCoordinates as c where c = :coordinate

Or using the with keyword:

select o from Overlay o join o.blocksCoordinates as c with c = :coordinate

Using that query should return any Overlay for which the join on c = coordinate succeeded.

Edit: Alternatively, try to use the x and y values:

select o from Overlay o join o.blocksCoordinates as c with c.x = :x and c.y = :y
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文