Hibernate Criteria: Perform JOIN in Subquery/DetachedCriteria

纵然是瞬间 提交于 2019-12-01 05:24:38

Don't you have a typo in your code at the following line :

criteria.add(Expression.eq("lang.langCode", "EN"));

I think, you should add this restriction on the subcriteria and not the criteria.

If you need to join tables in subquery can you try make this. It is explicitly specifying joinType in your detached criteria.

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