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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:13:02+00:00 2026-05-26T12:13:02+00:00

I have these twos sql scripts, and i’m getting some problems to perform the

  • 0

I have these twos sql scripts, and i’m getting some problems to perform
the translation in hql, to be used in a Query from JPA:

SELECT f.idprovider, pe.name from provider f
inner join person pe
on(f.idperson = pe.idperson) 
inner join product_provider pf
on(f.idprovider = pf.idprovider) 
inner join product p
on(pf.idproduct = p.idproduct)
inner join item i
on(p.idproduct = i.idproduct)
where i.iditem = 1



SELECT f.idprovider, pe.name, pe.cnpjf from product_provider pf
inner join provider f  
on(pf.idprovider = f.idprovider)
inner join coliseusys.person pe
on(f.idperson = pe.idperson)
inner join product p
on(pf.idproduct = p.idproduct)
where p.idproduct = (select p2.idproduct from item i inner join product p2
on(i.idproduct = p2.idproduct) where i.iditem = 1)

these sqls do the same thing, and i’ve tried a lot do take the hql from any of it, without results.
the mapping in hibernate is ok.

any idea?

  • 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-26T12:13:02+00:00Added an answer on May 26, 2026 at 12:13 pm

    The translation is immediate :

    select f.id, pe.name from Provider f
    inner join f.person pe
    inner join f.products p
    inner join p.items i
    where i.id = :itemId
    

    This is assuming that

    • Provider has a toOne association with Person
    • Provider has a toMany association with products, using the join table product_provider
    • Product has a OnetoMany association with Item

    If that’s not the case, then describe your mapping, because doing HQL without knowing the entities is impossible. It’s like doing SQL without knowing the tables.

    You should read http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#queryhql. It has lots of examples of HQL queries and explain how they work in great details.

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

Sidebar

Related Questions

I have these 2 mysql queryes SELECT `name` AS name1,`id` AS id1 FROM `table`
I have these code which I have converted from Java. Now I need to
i have these two tables , s(id,firstname,lastname,mydate,mount,sh) users(uid,email,password,nameoffice) and this query $sql=SELECT s.id,s.firstname,s.lastname,s.mydate,s.mount,users.nameOffice FROM
I have these two pieces of code, wich one is more readable? foreach decimal
I have these 3 tables + data: items : itemId, itemName data: 1, my
I have these 2 vectors: alpha = 1 1 1 1 1 1 1
I have these container objects (let's call them Container) in a list. Each of
I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int
I have these tables: Projects(projectID, CreatedByID) Employees(empID,depID) Departments(depID,OfficeID) Offices(officeID) CreatedByID is a foreign key
I have these 3 icons enclosed in separate DIVs all of which are enclosed

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.