diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java
index 25e52bf3a6..c472805cfd 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java
@@ -323,7 +323,7 @@ public abstract class SimpleValue implements KeyValue {
if ( rootClass != null ) {
params.setProperty( IdentifierGenerator.ENTITY_NAME, rootClass.getEntityName() );
params.setProperty( IdentifierGenerator.JPA_ENTITY_NAME, rootClass.getJpaEntityName() );
- params.setProperty( OptimizableGenerator.IMPLICIT_NAME_BASE, rootClass.getJpaEntityName() );
+ params.setProperty( OptimizableGenerator.IMPLICIT_NAME_BASE, getTable().getName() );
final StringBuilder tables = new StringBuilder();
final Iterator
itr = rootClass.getIdentityTables().iterator();
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/AbstractTPCAutoEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/AbstractTPCAutoEntity.java
new file mode 100644
index 0000000000..aaa2eee166
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/AbstractTPCAutoEntity.java
@@ -0,0 +1,30 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
+ * See the lgpl.txt file in the root directory or .
+ */
+package org.hibernate.orm.test.annotations.id.generationmappings;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+
+/**
+ * @author Christian Beikov
+ */
+@Entity
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+public abstract class AbstractTPCAutoEntity {
+ private Long id;
+
+ @Id @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long long1) {
+ id = long1;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/NewGeneratorMappingsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/NewGeneratorMappingsTest.java
index 0f335a0231..763923ab78 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/NewGeneratorMappingsTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/NewGeneratorMappingsTest.java
@@ -12,7 +12,6 @@ import org.hibernate.id.enhanced.NoopOptimizer;
import org.hibernate.id.enhanced.PooledOptimizer;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.id.enhanced.TableGenerator;
-import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DomainModel;
@@ -40,7 +39,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
AutoEntity.class,
MinimalTableEntity.class,
DedicatedSequenceEntity1.class,
- DedicatedSequenceEntity2.class
+ DedicatedSequenceEntity2.class,
+ AbstractTPCAutoEntity.class,
+ TPCAutoEntity1.class
},
annotatedPackageNames = {
"org.hibernate.orm.test.annotations.id.generationmappings"
@@ -89,6 +90,17 @@ public class NewGeneratorMappingsTest {
assertEquals( SequenceStyleGenerator.DEFAULT_INCREMENT_SIZE, seqGenerator.getDatabaseStructure().getIncrementSize() );
}
+ @Test
+ public void testTablePerClassAutoEntity(SessionFactoryScope scope) {
+ final EntityPersister persister = scope.getSessionFactory().getEntityPersister( AbstractTPCAutoEntity.class.getName() );
+ IdentifierGenerator generator = persister.getIdentifierGenerator();
+ assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
+ SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
+ assertEquals( "AbstractTPCAutoEntity_SEQ", seqGenerator.getDatabaseStructure().getName() );
+ assertEquals( SequenceStyleGenerator.DEFAULT_INITIAL_VALUE, seqGenerator.getDatabaseStructure().getInitialValue() );
+ assertEquals( SequenceStyleGenerator.DEFAULT_INCREMENT_SIZE, seqGenerator.getDatabaseStructure().getIncrementSize() );
+ }
+
@Test
public void testMinimalTableEntity(SessionFactoryScope scope) {
final EntityPersister persister = scope.getSessionFactory().getEntityPersister( MinimalTableEntity.class.getName() );
@@ -115,7 +127,7 @@ public class NewGeneratorMappingsTest {
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
assertEquals(
- StringHelper.unqualifyEntityName( DedicatedSequenceEntity1.class.getName() ) + DedicatedSequenceEntity1.SEQUENCE_SUFFIX,
+ "DEDICATED_SEQ_TBL1" + DedicatedSequenceEntity1.SEQUENCE_SUFFIX,
seqGenerator.getDatabaseStructure().getName()
);
@@ -125,7 +137,7 @@ public class NewGeneratorMappingsTest {
assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
seqGenerator = (SequenceStyleGenerator) generator;
assertEquals(
- DedicatedSequenceEntity2.ENTITY_NAME + DedicatedSequenceEntity1.SEQUENCE_SUFFIX,
+ "DEDICATED_SEQ_TBL2" + DedicatedSequenceEntity1.SEQUENCE_SUFFIX,
seqGenerator.getDatabaseStructure().getName()
);
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/TPCAutoEntity1.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/TPCAutoEntity1.java
new file mode 100644
index 0000000000..90acef28a8
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/generationmappings/TPCAutoEntity1.java
@@ -0,0 +1,24 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
+ * See the lgpl.txt file in the root directory or .
+ */
+package org.hibernate.orm.test.annotations.id.generationmappings;
+import javax.persistence.Entity;
+
+/**
+ * @author Christian Beikov
+ */
+@Entity
+public class TPCAutoEntity1 extends AbstractTPCAutoEntity {
+ private String name1;
+
+ public String getName1() {
+ return name1;
+ }
+
+ public void setName1(String name1) {
+ this.name1 = name1;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java
index 57c94d0aed..b67ac80efe 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java
@@ -79,7 +79,7 @@ public class AutoGenerationTypeTests {
final DatabaseStructure database1Structure = entityIdGenerator.getDatabaseStructure();
// implicit name : `${entity-name}_seq`
- assertThat( database1Structure.getName(), equalToIgnoringCase( "Entity1_seq" ) );
+ assertThat( database1Structure.getName(), equalToIgnoringCase( "tbl_1_SEQ" ) );
assertThat( database1Structure.getIncrementSize(), is( 50 ) );
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/sequence/BasicSequenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/sequence/BasicSequenceTest.java
index 1f666ee10a..f406637877 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/sequence/BasicSequenceTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/sequence/BasicSequenceTest.java
@@ -72,7 +72,7 @@ public class BasicSequenceTest {
assertThat( persister.getIdentifierGenerator(), instanceOf( SequenceStyleGenerator.class ) );
final SequenceStyleGenerator generator = (SequenceStyleGenerator) persister.getIdentifierGenerator();
- assertEquals( overriddenEntityName + SequenceStyleGenerator.DEF_SEQUENCE_SUFFIX, generator.getDatabaseStructure().getName() );
+ assertEquals( "ID_SEQ_BSC_ENTITY" + SequenceStyleGenerator.DEF_SEQUENCE_SUFFIX, generator.getDatabaseStructure().getName() );
scope.inTransaction(
(s) -> {