JPA join entity on the same entity

青春壹個敷衍的年華 提交于 2019-12-06 16:47:24

Ok, I'll answer myself.

1st way:

SELECT parent.id, child FROM Entity parent, IN(parent.children) child

2nd way:

SELECT parent.id, child FROM Entity parent, Entity child WHERE child MEMBER OF parent.children

Only the 2nd query is extremely dangerous, it generates very heavy cross-join sql query with IN. If somebody has a better solution - I'd really apreciate if you share, I haven't solved the whole task yet.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!