Skip to content

Commit 0431d15

Browse files
beikovdreab8
authored andcommitted
HHH-19740 Delegate table related resolving to mutating table reference
1 parent 3863d8f commit 0431d15

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/MutatingTableReferenceGroupWrapper.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ public TableReference getTableReference(
6262
NavigablePath navigablePath,
6363
String tableExpression,
6464
boolean resolve) {
65-
return mutatingTableReference.getTableExpression().equals( tableExpression )
66-
? mutatingTableReference
67-
: null;
65+
return mutatingTableReference.getTableReference( tableExpression );
6866
}
6967

7068
@Override
7169
public void applyAffectedTableNames(Consumer<String> nameCollector) {
72-
nameCollector.accept( mutatingTableReference.getTableExpression() );
70+
mutatingTableReference.applyAffectedTableNames( nameCollector);
7371
}
7472

7573
@Override
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.orm.test.query.mutationquery;
6+
7+
import java.util.List;
8+
9+
import org.hibernate.testing.orm.junit.DomainModel;
10+
import org.hibernate.testing.orm.junit.Jira;
11+
import org.hibernate.testing.orm.junit.SessionFactory;
12+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
13+
import org.junit.jupiter.api.Test;
14+
15+
import jakarta.persistence.ElementCollection;
16+
import jakarta.persistence.Entity;
17+
import jakarta.persistence.Id;
18+
import jakarta.persistence.Inheritance;
19+
import jakarta.persistence.InheritanceType;
20+
21+
@SessionFactory
22+
@DomainModel(annotatedClasses = {
23+
MutationQueriesCollectionTableTest.Base1.class,
24+
MutationQueriesCollectionTableTest.Table1.class
25+
})
26+
@Jira("https://hibernate.atlassian.net/browse/HHH-19740")
27+
public class MutationQueriesCollectionTableTest {
28+
29+
@Test
30+
public void testDelete(SessionFactoryScope scope) {
31+
scope.inTransaction( session -> {
32+
session.createQuery( "delete from Table1 where name = :name" )
33+
.setParameter( "name", "test" )
34+
.executeUpdate();
35+
} );
36+
}
37+
38+
@Entity(name = "Base1")
39+
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
40+
public abstract static class Base1 {
41+
42+
@Id
43+
private Long id;
44+
45+
@SuppressWarnings("unused")
46+
private String name;
47+
48+
@ElementCollection
49+
private List<String> roles;
50+
51+
}
52+
53+
@Entity(name = "Table1")
54+
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
55+
public static class Table1 extends Base1 {
56+
57+
}
58+
}

0 commit comments

Comments
 (0)