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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:33:21+00:00 2026-06-07T13:33:21+00:00

Possible Duplicate: SQL Query with MySQL I implement a Rest Web Service (JAX-RS) using

  • 0

Possible Duplicate:
SQL Query with MySQL

I implement a Rest Web Service (JAX-RS) using Jersey in Java. I use hibernate to fetch the data from MySQL database.
With this query:

(Select distinct deliverable.id from Task as t where t.project.id= :id And t.user.username = :name order by t.id desc")
                    .setMaxResults(3)
                    .setLong("id", projectId)
                    .setString("name", username)
                    .list();

I have a right result which is : [275,51,286]. This is the provided key for every id in the database:

    id       key
---------------------
    275      2.0
    51       cm
    286      19.87

Now I use this query (Everything is the same except deliverable.key instead of deliverable.id) :

(Select distinct deliverable.key from Task as t where t.project.id= :id And t.user.username = :name order by t.id desc")
                    .setMaxResults(3)
                    .setLong("id", projectId)
                    .setString("name", username)
                    .list();

The result is: [“2.0″,”19.88″,”19.99”]. The first one is right, but the second and third one are completely different keys.

Maybe it can be solved by “alias” or any other way. your suggestion?

  • 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-07T13:33:26+00:00Added an answer on June 7, 2026 at 1:33 pm

    I found the answer:

    ("select d.key from Deliverable as d, Task as t
                    where t.deliverable.id = d.id and
                    t.id = (select max(t1.id) from Task t1 where t1.deliverable.id = d.id)
                    and d.project.id= :id
                    and t.user.username = :name
                    order by t.id desc")
            .setMaxResults(3)
            .setLong("id", projectId)
            .setString("name", username)
            .list();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I Create a Comma-Separated List using a SQL Query? I
Possible Duplicate: sql query with jdbc How dow e find the wuery frok mysql.
Possible Duplicate: Simulating group_concat MySQL function in MS SQL Server 2005? SQL Query for
Possible Duplicate: SQL Server Database query help Hi, I have a problem that I
Possible Duplicate: Writing an SQL query to SELECT item from the following table I
Possible Duplicate: linq to sql recursive query I got stuck with having to build
Possible Duplicate: What does the colon sign “:” do in a SQL query? Simple
Possible Duplicate: SQL Select within 24 hours? I am using regular SQL to attempt
Possible Duplicate: Equivalent of LIMIT and OFFSET for SQL Server? this is a mysql
Possible Duplicate: Why would someone use WHERE 1=1 AND <conditions> in a SQL clause?

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.