Skip to content

Commit 7be9bbc

Browse files
committed
HHH-19745 Test subquery that shadows alias of outer query to stress identity sensitive operations
1 parent 4c8dd9c commit 7be9bbc

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.orm.test.query;
6+
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.Id;
10+
import org.hibernate.testing.orm.junit.DomainModel;
11+
import org.hibernate.testing.orm.junit.Jira;
12+
import org.hibernate.testing.orm.junit.SessionFactory;
13+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
14+
import org.junit.jupiter.api.Test;
15+
16+
17+
@DomainModel(
18+
annotatedClasses = {
19+
SubQueryShadowingTest.TestEntity.class,
20+
}
21+
)
22+
@SessionFactory
23+
public class SubQueryShadowingTest {
24+
25+
@Test
26+
@Jira("https://hibernate.atlassian.net/browse/HHH-19745")
27+
public void testSelectCase(SessionFactoryScope scope) {
28+
scope.inTransaction( session -> {
29+
session.createQuery(
30+
"""
31+
from TestEntity t
32+
left join TestEntity t2 on exists (
33+
select 1
34+
from TestEntity t
35+
order by t.id
36+
limit 1
37+
)
38+
""", TestEntity.class )
39+
.list();
40+
} );
41+
}
42+
43+
@Entity(name = "TestEntity")
44+
public static class TestEntity {
45+
46+
@Id
47+
@GeneratedValue
48+
private Long id;
49+
50+
private String name;
51+
52+
public TestEntity() {
53+
}
54+
55+
public TestEntity(String name) {
56+
this.name = name;
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)