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 8911317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:54:45+00:00 2026-06-15T03:54:45+00:00

In the below query on passing a list of office codes, I get a

  • 0

In the below query on passing a list of office codes, I get a list of countryID’s. Now instead of that, I need a Map In which the key will be countryID and its value as the list of office codes. Can you please help me.

Example: If we have offices as abc, def belong to country 123 and xyz belongs to 789, I need a Map like
(123, List(abc,def)…. (789,List(xyz)))

public List getData(List officeCode) {

    try {
        StringBuffer queryString = new StringBuffer("select distinct 
        (abc.countryID)  from com.#####.TABLE table");
        queryString.append(" where table.officeCode in (:oCode)");
        return SessionFactory.getCurrentSession()
        .createQuery(queryString.toString())
        .setParameterList("oCode",officeCode )
        .list();
    }
    catch (Exception e)

    {
        e.printStackTrace();
        return null;
    }

}
  • 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-15T03:54:47+00:00Added an answer on June 15, 2026 at 3:54 am

    Execute the following query:

    select distinct abc.countryID, abc.officeCode from SomeEntity abc where abc.officeCode in (:codes)
    

    This query will return a List<Object[]>, each object array containing a countryID as first element and an office code as second element.

    Then iterate through the list, and populate your map.

    Note: using a StringBuffer to concatenate String literals is counter-productive, and less readable. You’d better simply do:

    String queryString = "select distinct (abc.countryID)  from com.#####.TABLE table"
                         + " where table.officeCode in (:oCode)";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now the below query returns 1 row for each result.... I need to
I am using the below query to return the names of artists which appear
I'm using below query to count the daily result, but now I'm make it
UPDATE After passing execute() a list of rows as per Nathan's suggestion, below, the
I am trying to use the query below (which works perfectly), as a subquery
I would like to execute the below query by passing some values from applet
Below is my shell script from which I am running my Hive query. In
I have a Stored Proc query below which involves returning partial delimited search string.
I have the below query in a postgresql database SELECT * FROM accounts where
I run the below query..... SELECT SUM(PAPostedTotalCostN) AS Total_Cost FROM PA01201 WHERE PA01201.PAcontid =

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.