掲示板
Custom FinderImpl Not working with IN-Clause and Having
7年前 に Debopam Mitra によって更新されました。
Custom FinderImpl Not working with IN-Clause and Having
Junior Member 投稿: 39 参加年月日: 12/09/27 最新の投稿
I have a custom SQL like the following:
The FinderImpl code looks like this:
The SQL is correct as it is showing the results when executed in MySQL prompt. But the same is giving 0 results. Further investigating I found that if I am providing only one categoryId it's giving me results.
Can any one tell what might be the problem?
SELECT {pm.*} FROM productmaster pm
INNER JOIN productcategories pc USING(productId)
WHERE pc.categoryId IN (?)
GROUP BY pc.courseId
HAVING COUNT(DISTINCT pc.categoryId) >= ?
The FinderImpl code looks like this:
SQLQuery sqlQuery = session.createSQLQuery(customSQL);
sqlQuery.addEntity("pm", ProductMasterImpl.class);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
String filterCategoryIdsMerge = StringUtil.merge(filterCategoryIds, StringPool.COMMA_AND_SPACE);
queryPos.add(filterCategoryIdsMerge);
queryPos.add(filterCategoryIds.length);
productMasters = (List<productmaster>) sqlQuery.list();</productmaster>
The SQL is correct as it is showing the results when executed in MySQL prompt. But the same is giving 0 results. Further investigating I found that if I am providing only one categoryId it's giving me results.
Can any one tell what might be the problem?
7年前 に David H Nebinger によって更新されました。
RE: Custom FinderImpl Not working with IN-Clause and Having
Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
where pc.category in (list) having count(distinct matches) >= list length?
Are you sure that's what you're going after?
Are you sure that's what you're going after?