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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:50:41+00:00 2026-06-13T21:50:41+00:00

I am using hibernate to connect to my database for a project. I would

  • 0

I am using hibernate to connect to my database for a project.

I would like to have a query that gets the products out of my database with the discription and name in a certain language. The parameter I have is the short name for the language, so first I would have to get the id of the language and then get the text in the required languages.

I have tried the following hql query, without success.

from Products as p
where p.productlanguages.languages.shortname like 'eng'

This is an image of the part of the database where the data should come from:
database

I have got the desired result with an sql query, but I can’t seem to get it to work in hibernate. But I would prefer to do this in hql.

SELECT * FROM products p 
INNER JOIN productlanguage pl ON pl.Products_id = p.id 
WHERE pl.Languages_id = 
(
SELECT id FROM languages 
WHERE Shortname = 'eng'
);

Could anyone tell me how to build this hql query?
Thank you.

  • 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-13T21:50:43+00:00Added an answer on June 13, 2026 at 9:50 pm

    Try below:

       from Products p INNER JOIN p.productlanguages pl
       where pl.languages.shortname ='eng'
    

    I am assuming that you have mapped Product-Productlanguages relationship as OneToMany and Productlanguages-Langages relationship as ManyToOne as depicted in your E-R diagram.

    EDIT: There seems to be a typo in Productlanguage mapping at line public Languages getLanguages() {barcode, remove the barcode in the end.

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="Languages_id", nullable=false, insertable=false, updatable=false)
    public Languages getLanguages() {barcode
    
        return this.languages;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JPA with Hibernate to connect to a Postgres database, and I'm unable
I working on a project where I have to connect the specific database based
I have a really strange issue when using hibernate to connect to a MySQLDB
Im using hibernate to connect to a oracle database in my application. When the
I'm currently using Spring+Hibernate+MySQL for a project I'm working on. I realized that a
Can I configure hibernate properties to connect without using an instance name to sql
How can I connect to more than one mysql database dynamically using Hibernate?
I have some web-project (Spring MVC + Hibernate). For hibernate objects I am using
I am trying to connect to an Oracle Database using nHibernate. I can connect
When using Hibernate 2nd level cache and query cache and not specifying anything inside

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.