HQL Subquery Query Select
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 ...
Co开发者_高级运维ordinate 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?
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
精彩评论