jpa lazy fetch entities over multiple levels with criteria api

蓝咒 提交于 2019-12-03 06:56:47

It does not work with JPQL and there is no way to make it work in CriteriaQueries either. Specification limits fetched entities to the ones in that are referenced directly from the returned entity:

About fetch join with CriteriaQuery:

An association or attribute referenced by the fetch method must be referenced from an entity or embeddable that is returned as the result of the query.

About fetch join in JPQL:

The association referenced by the right side of the FETCH JOIN clause must be an association or ele ment collection that is referenced from an entity or embeddable that is returned as a result of the query.

Same limitation is also told in OpenJPA documentation.

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