OneToOne association cannot be fetched with a single query in Hibernate

Solution Unverified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7
  • Hibernate 5

Issue

  • A OneToOne association is defined between two entities (e.g. Customer and Address)
  • An HQL/JPAQL query like select c from Customer c join fetch c.address results in two distinct SQL queries

Resolution

Root Cause

This is a known defect (Content from hibernate.atlassian.net is not included.HHH-3930).

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.