diff --git a/orm/hibernate-orm-6/pom.xml b/orm/hibernate-orm-6/pom.xml
index 39a4b4c8..9536e0c6 100644
--- a/orm/hibernate-orm-6/pom.xml
+++ b/orm/hibernate-orm-6/pom.xml
@@ -10,7 +10,7 @@
2.3.230
4.13.2
- 6.5.2.Final
+ 6.6.0.CR1
@@ -54,8 +54,8 @@
maven-compiler-plugin
3.13.0
-
- 11
+
+ 17
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ToOneJoinFetchTest.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ToOneJoinFetchTest.java
new file mode 100644
index 00000000..11b6d5df
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ToOneJoinFetchTest.java
@@ -0,0 +1,47 @@
+package org.hibernate.bugs;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.Persistence;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class ToOneJoinFetchTest {
+
+ private EntityManagerFactory entityManagerFactory;
+
+ @Before
+ public void init() {
+ entityManagerFactory = Persistence.createEntityManagerFactory("templatePU");
+ }
+
+ @After
+ public void destroy() {
+ entityManagerFactory.close();
+ }
+
+ @Test
+ public void testToOneAttributeJoinFetch() throws Exception {
+ EntityManager entityManager = entityManagerFactory.createEntityManager();
+ entityManager.getTransaction().begin();
+
+ //language=HQL
+ var hql = """
+ SELECT a_entity FROM org.hibernate.entities.AEntity a_entity
+ LEFT JOIN FETCH a_entity.b_entity b_entity
+ LEFT JOIN FETCH b_entity.c_entities c_entities
+ """;
+
+ var query = entityManager.createQuery(hql, List.class);
+ var res = query.getResultList();
+
+ assertEquals(0, res.size());
+ entityManager.getTransaction().commit();
+ entityManager.close();
+ }
+}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/AEntity.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/AEntity.java
new file mode 100644
index 00000000..8f024289
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/AEntity.java
@@ -0,0 +1,23 @@
+package org.hibernate.entities;
+
+import jakarta.persistence.*;
+
+import static jakarta.persistence.GenerationType.IDENTITY;
+
+@Entity
+@Table(name = "a_entities")
+public class AEntity {
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue(strategy = IDENTITY)
+ private Long id;
+
+ @OneToOne
+ @JoinColumn(name = "b_entity_id", updatable = false, insertable = false)
+ private B2Entity b_entity;
+
+ @Column(name = "b_entity_id")
+ private Long b_entity_id;
+
+}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/B1Entity.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/B1Entity.java
new file mode 100644
index 00000000..b4c51a4d
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/B1Entity.java
@@ -0,0 +1,9 @@
+package org.hibernate.entities;
+
+import jakarta.persistence.Entity;
+import jakarta.persistence.Table;
+
+@Entity
+@Table(name = "b_entities")
+public class B1Entity extends BaseBEntity {
+}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/B2Entity.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/B2Entity.java
new file mode 100644
index 00000000..c36d475c
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/B2Entity.java
@@ -0,0 +1,9 @@
+package org.hibernate.entities;
+
+import jakarta.persistence.Entity;
+import jakarta.persistence.Table;
+
+@Entity
+@Table(name = "b_entities")
+public class B2Entity extends BaseBEntity {
+}
\ No newline at end of file
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/BaseBEntity.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/BaseBEntity.java
new file mode 100644
index 00000000..5ec00f49
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/BaseBEntity.java
@@ -0,0 +1,21 @@
+package org.hibernate.entities;
+
+import jakarta.persistence.*;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static jakarta.persistence.GenerationType.IDENTITY;
+
+@MappedSuperclass
+public class BaseBEntity {
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue(strategy = IDENTITY)
+ private Long id;
+
+ @OneToMany(mappedBy = "b_entity")
+ private Set c_entities = new LinkedHashSet<>();
+
+}
diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/CEntity.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/CEntity.java
new file mode 100644
index 00000000..f6f1235b
--- /dev/null
+++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/entities/CEntity.java
@@ -0,0 +1,23 @@
+package org.hibernate.entities;
+
+import jakarta.persistence.*;
+
+import static jakarta.persistence.GenerationType.IDENTITY;
+
+@Entity
+@Table(name = "c_entities")
+public class CEntity {
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue(strategy = IDENTITY)
+ private Long id;
+
+ @Column(name = "b_id")
+ private Long bEntityId;
+
+ @ManyToOne
+ @JoinColumn(name = "b_id", updatable = false, insertable = false)
+ private B1Entity b_entity;
+
+}
\ No newline at end of file