Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:31:23+00:00 2026-06-04T17:31:23+00:00

I am using Liferay 6.1, Tomcat and MySQL. I have a custom-sql sentence for

  • 0

I am using Liferay 6.1, Tomcat and MySQL. I have a custom-sql sentence for a list portlet. The custom-sql uses two parameters: an array of groupIds and a result limit.

SELECT
count(articleId) as count,
...
FROM comments
WHERE groupId IN (?)
GROUP BY articleId
ORDER BY count DESC 
LIMIT 0, ?

My FinderImpl class has this method:

 public List<Comment> findByMostCommented(String groupIds, long maxItems) {

    Session session = null;
    session = openSession();

    String sql = CustomSQLUtil.get(FIND_MOST_COMMENTS);

    SQLQuery query = session.createSQLQuery(sql);
    query.addEntity("Comment", CommentImpl.class);

    QueryPos queryPos = QueryPos.getInstance(query);
    queryPos.add(groupIds);
    queryPos.add(maxItems);

    List<Comment> queryResult = query.list();

    return queryResult;
}

This returns 0 results. If I remove the WHERE IN(), it works.

Is IN a valid operator? If not, how can search within different groups?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:31:23+00:00Added an answer on June 4, 2026 at 5:31 pm

    Perhaps hibernate is quoting your string of groupIds (presumably it is in the form of "1,2,3,4" and when hibernate translates this to sql it is putting quotes around it for you?

    You may want to try something like this (from Liferay itself):

    String sql = CustomSQLUtil.get(FIND_BY_C_C);
    
    sql = StringUtil.replace(sql, "[$GROUP_IDS$]", groupIds);
    

    And include ([$GROUP_IDS$]) in place of the (?) in your SQL

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a portlet for Liferay (using Tomcat and Spring) and
Im new with liferay have a problem with portlet deployment using the plugins sdk,
I am using Liferay 6 for development , i have developed Liferay6 Struts2 Portlet
I am using Liferay 6 . I have read that Liferay Hooks can be
I am trying to create a simple portlet for Liferay 5.2.2 using Grails 1.2.1
I'm loading yui.js 3.3.0 version file from portlet but liferay its using 3.2.0 yui.js
I have a JSP, say view.jsp , that's using the basic Liferay search container
I am trying to make a hook for the Liferay announcements portlet using the
I have a question regarding the development of liferay portlets using the liferay plugin
I faced problem in Icefaces portlet using portletfaces bridge inside liferay. the problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.