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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:22:31+00:00 2026-05-27T05:22:31+00:00

I have a table with 4 columns : id, column_a and column_b My initial

  • 0

I have a table with 4 columns : id, column_a and column_b

My initial query is basicaly

Session session = initialize my hibernate session;
Criteria criteria = session.createCriteria(MytableBean.class);
// add some constraints
return criteria.list()

And it returns some results like :

id  |  column_a  | column_b | 
1   |  A         | 1        | 
2   |  A         | 1        | 
3   |  A         | 2        | 
4   |  B         | 3        | 
5   |  B         | 3        | 

But I don’t want to get several times the same couple (column_a, column_b), even if I need to have it many times in my database.

So, I’m looking for a query which returns a result similar to:

id  |  column_a  | column_b | 
    |  A         | 1        | 
    |  A         | 2        | 
    |  B         | 3        | 

In sql I would use SELECT DISTINCT column_a, column_b FROM ....

But I can’t use sql (and either don’t want to use hql, as far as possible).

  • 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-05-27T05:22:32+00:00Added an answer on May 27, 2026 at 5:22 am

    The following will accomplish this. A list of Object[] will be returned.

        Criteria criteria = session.createCriteria(MytableBean.class);
        ProjectionList projList = Projections.projectionList();
        projList.add(Projections.property("column_a"));
        projList.add(Projections.property("column_b"));
        projList.add(Projections.groupProperty("column_a"));
        projList.add(Projections.groupProperty("column_b"));
    
        criteria.setProjection(projList);
        return criteria.list();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two columns (A and B) in a table: column_A column_B 10 alb
I have the following table: column_a column_b column_c column_d column_date 1 test_1 test_1 type_1
I have a table with two columns: column A column B 1 2 1
I have table with 3 columns A B C. I want to select *
I have a table with the following columns: A B C --------- 1 10
I have a table y Which has two columns a and b Entries are:
Suppose I have a database table with columns a, b, and c. I plan
I have an index on columns A, B, C, D of table T I
Assume I have a table called table and I have 3 columns, a, b,
I have a table called scheduler_sched which has several columns, including a column called

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.