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

  • Home
  • SEARCH
  • 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 198209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:55:07+00:00 2026-05-11T16:55:07+00:00

I am having a querying issue in Hibernate. I have a table, ‘test’, with

  • 0

I am having a querying issue in Hibernate. I have a table, ‘test’, with existing data. I have a requirement where I can not modify the schema of the test table, so I created another table, ‘testExtension’, whose primary key is a foreign key to the primary key of Test. Data in testExtension is a subset of the data in test. i.e. There will be less rows in ‘testExtension’ than in ‘test’.

I have defined this relationship in a configuration file as follows:

<class name="Test" table="test">
<id name="testId" column="test_id">
    <generator class="sequence">
        <param name="sequence">test_id_seq</param> 
    </generator>
</id>

<property name="name"/>


<joined-subclass name="TestExtension" table="testExtension">
    <key column="test_id"/>

    <property name="summary" />
    <property name="homepage"/>
</joined-subclass>

With this setup, I am able to create a TestExtension object in my Java program, populate it with data, ‘save’ it via Hibernate, and commit the transaction. And it correctly saves data in both Test and TestExtension.

My problem is occurring when I am trying to query data from these tables. Right now if I query for a particular test_id using the TestExtension.class to QBE, it will only return a row if that id exists in both Test and TestExtension. If I use the Test.class to QBE, it will return the row but I will not have access to any of the data stored in TestExtension.

My question is: how can I query these tables so that the results are based off a ‘left outer join’ of both Test and TestExtension? Any solution is appreciated, whether it’s query by example, HQL, or something else (though preferably not raw SQL).

Thanks!

  • 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-11T16:55:07+00:00Added an answer on May 11, 2026 at 4:55 pm

    HQL is probably the easiest way to do this. Docs are here:

    http://docs.jboss.org/hibernate/stable/core/reference/en/html/queryhql-joins.html

    Sounds like what you might want to do is remap your relationships so that Test and TestExtension use a one-to-one relationship instead of inheritance. Then you can query for Test and TestExtension using a left outer join across the one-to-one.

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

Sidebar

Ask A Question

Stats

  • Questions 243k
  • Answers 243k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Put a transparent UIView atop your table view, override its… May 13, 2026 at 7:48 am
  • Editorial Team
    Editorial Team added an answer unbind only removes events added by jQuery. That is, this… May 13, 2026 at 7:48 am
  • Editorial Team
    Editorial Team added an answer something like this: ... <body> <div id="jsNotify"><p>This page works best… May 13, 2026 at 7:48 am

Related Questions

I am having a querying issue in Hibernate. I have a table, 'test', with
I am currently messing around with some stuff for an idea for a site
I'm having issues escaping/stripping strings with PHP/MySQL - there always seems to be redundant
I am having a problem mapping. I was reading scottGU post of data shaping
I am using LINQ and am having a hard time understanding how I can

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.