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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:00:18+00:00 2026-05-31T08:00:18+00:00

I have a following entity structure. Venue — n:1 — Schedule — 1:n —

  • 0

I have a following entity structure.

Venue -- n:1 -- Schedule -- 1:n -- Event

I have a query to get counts of all schedule in Venues:

SELECT v, count(s.event) FROM Venue v 
LEFT JOIN i.schedule s 
GROUP BY i.id ORDER BY count(s.event) asc;

The problem is that this query will never output venues, that have zero events. The problem is with Hibernate, which generates following:

select ..., count(schedule4_.event_id) as col_7_0_ 
from Venue venue0_ 
left outer join event_schedule schedule4_ on venue0_.id=schedule4_.venue_id, 
  Event event5_
where schedule4_.event_id=event5_.id and ...

You can see, that Hibernate tries to join Event on Schedule even though I did not request that. Obviously if the Schedule does not exist, joining Event does not make any sense.

(I simpified the query, if there is some typo, it should not have any impact on the problem).

  • 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-31T08:00:18+00:00Added an answer on May 31, 2026 at 8:00 am

    Try with the following query:

    select v.id, count(e.id) from Venue v 
    left join v.schedule s 
    left join s.events e
    group by v.id order by count(e.id) asc;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following entity structure: public class Party { public Int32 PartyId {
I have the following table structure, which is imported into an Entity Framework project:
I have a problem with the following Linq query using Entity Framework: from o
I have a database with the following structure: CREATE TABLE entity ( id SERIAL,
Let's say I have the following class structure: /** Boring bits snipped */ @Entity
I'm trying to get the following query to work in Hibernate: SELECT m FROM
I have the following entity structure: Business --> Campaign --> Promotion, where ONE Business
I have the following table structure which has been imported into the Entity Framework.
I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue
I have two entity classes annotated in the following way @Entity class A {

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.