Skip to content

Commit c3cefd7

Browse files
dreab8yrodiere
authored andcommitted
HHH-15115 Deleting an entity with Joined inheritance and default schema set is throwing and error
1 parent 83b6e6e commit c3cefd7

File tree

5 files changed

+128
-4
lines changed

5 files changed

+128
-4
lines changed

hibernate-core/src/main/java/org/hibernate/hql/spi/id/cte/AbstractCteValuesListBulkIdHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected String determineIdTableName(Queryable persister) {
7272
"HT_" + StringHelper.unquote( persister.getTableName(), jdbcEnvironment.getDialect() )
7373
).render();
7474

75-
return persister.getFactory().getSqlStringGenerationContext().format(
75+
return persister.getFactory().getSqlStringGenerationContext().formatWithoutDefaults(
7676
new QualifiedTableName(
7777
Identifier.toIdentifier( catalog ),
7878
Identifier.toIdentifier( schema ),

hibernate-core/src/main/java/org/hibernate/hql/spi/id/global/GlobalTemporaryTableBulkIdStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected IdTableInfoImpl buildIdTableInfo(
112112
context.dropStatements.add( buildIdTableDropStatement( idTable, sqlStringGenerationContext ) );
113113
}
114114

115-
final String renderedName = sqlStringGenerationContext.format( idTable.getQualifiedTableName() );
115+
final String renderedName = sqlStringGenerationContext.formatWithoutDefaults( idTable.getQualifiedTableName() );
116116

117117
return new IdTableInfoImpl( renderedName );
118118
}

hibernate-core/src/main/java/org/hibernate/hql/spi/id/local/LocalTemporaryTableBulkIdStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected IdTableInfoImpl buildIdTableInfo(
119119
context.dropStatements.add( dropStatement );
120120
}
121121
return new IdTableInfoImpl(
122-
sqlStringGenerationContext.format( idTable.getQualifiedTableName() ),
122+
sqlStringGenerationContext.formatWithoutDefaults( idTable.getQualifiedTableName() ),
123123
buildIdTableCreateStatement( idTable, metadata, sqlStringGenerationContext ),
124124
dropStatement
125125
);

hibernate-core/src/main/java/org/hibernate/hql/spi/id/persistent/PersistentTableBulkIdStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected IdTableInfoImpl buildIdTableInfo(
127127
MetadataImplementor metadata,
128128
PreparationContextImpl context,
129129
SqlStringGenerationContext sqlStringGenerationContext) {
130-
final String renderedName = sqlStringGenerationContext.format( idTable.getQualifiedTableName() );
130+
final String renderedName = sqlStringGenerationContext.formatWithoutDefaults( idTable.getQualifiedTableName() );
131131

132132
context.creationStatements.add( buildIdTableCreateStatement( idTable, metadata,
133133
sqlStringGenerationContext
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package org.hibernate.test.inheritance;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.Id;
5+
import javax.persistence.Inheritance;
6+
import javax.persistence.InheritanceType;
7+
8+
import org.hibernate.cfg.AvailableSettings;
9+
import org.hibernate.cfg.Configuration;
10+
import org.hibernate.dialect.PostgreSQL81Dialect;
11+
12+
import org.hibernate.testing.RequiresDialect;
13+
import org.hibernate.testing.TestForIssue;
14+
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
15+
import org.junit.Before;
16+
import org.junit.Test;
17+
18+
@RequiresDialect(PostgreSQL81Dialect.class)
19+
@TestForIssue( jiraKey = "HHH-15115")
20+
public class JoinedInheritanceDeletionTest extends BaseCoreFunctionalTestCase {
21+
22+
@Override
23+
protected void configure(Configuration configuration) {
24+
configuration.setProperty( AvailableSettings.DEFAULT_SCHEMA, "public" );
25+
}
26+
27+
@Override
28+
protected Class<?>[] getAnnotatedClasses() {
29+
return new Class[] {
30+
Person.class,
31+
Employee.class,
32+
Customer.class
33+
};
34+
}
35+
36+
@Before
37+
public void setUp() {
38+
inTransaction(
39+
session -> {
40+
Person person = new Person( 1, "Bob" );
41+
Employee employee = new Employee( 2, "Chris", "Software Engineer" );
42+
Customer customer = new Customer( 3, "Miriam", "" );
43+
44+
session.save( person );
45+
session.save( employee );
46+
session.save( customer );
47+
}
48+
);
49+
}
50+
51+
@Test
52+
public void testDelete() {
53+
inTransaction(
54+
session -> {
55+
session.createQuery( "delete from Person" ).executeUpdate();
56+
}
57+
);
58+
}
59+
60+
@Entity(name = "Person")
61+
@Inheritance(strategy = InheritanceType.JOINED)
62+
public static class Person {
63+
64+
@Id
65+
private Integer id;
66+
67+
private String name;
68+
69+
public Person() {
70+
}
71+
72+
public Person(Integer id, String name) {
73+
this.id = id;
74+
this.name = name;
75+
}
76+
77+
public Integer getId() {
78+
return id;
79+
}
80+
81+
public String getName() {
82+
return name;
83+
}
84+
85+
}
86+
87+
@Entity(name = "Customer")
88+
public static class Customer extends Person {
89+
90+
private String comments;
91+
92+
public Customer() {
93+
}
94+
95+
public Customer(Integer id, String name, String comments) {
96+
super( id, name );
97+
this.comments = comments;
98+
}
99+
100+
public String getComments() {
101+
return comments;
102+
}
103+
104+
}
105+
106+
@Entity(name = "Employee")
107+
public static class Employee extends Person {
108+
109+
private String title;
110+
111+
public Employee() {
112+
}
113+
114+
public Employee(Integer id, String name, String title) {
115+
super( id, name );
116+
this.title = title;
117+
}
118+
119+
public String getTitle() {
120+
return title;
121+
}
122+
}
123+
124+
}

0 commit comments

Comments
 (0)