[JIRA] (HHH-16765) Hibernate 6 Cannot parse table name
by Culeafa Mihai (JIRA)
Culeafa Mihai ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMGM0ODRhOTRi... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16765?atlOrigin=eyJpIjoiMGM0OD... ) HHH-16765 ( https://hibernate.atlassian.net/browse/HHH-16765?atlOrigin=eyJpIjoiMGM0OD... ) Hibernate 6 Cannot parse table name ( https://hibernate.atlassian.net/browse/HHH-16765?atlOrigin=eyJpIjoiMGM0OD... )
Change By: Culeafa Mihai ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... )
Entities using the annotations {{@GeneratedValue}}, {{@GenericGenerator }}and {{@SecondaryTable }}that have a table name not following the standard format of {{"schema.catalog.tableName"}} cannot be parsed regardless of physical-strategy property. Example table name:{{com.proj.db::base.folder}}. Adding quotes does not fix the issue.
This issues has appeared in versions later that {{6.1.3}} (last version without the issue).
Example Entity:
{noformat}@Entity
@Table(name = Folder.TABLE_NAME)
@SecondaryTable(name = RelationView.TABLE_NAME, pkJoinColumns = @PrimaryKeyJoinColumn(name = "NODE"))
@JsonIgnoreProperties(ignoreUnknown = true)
public class Folder extends Entity<Folder, Integer> {
public static final String TABLE_NAME_NO_QUOTES = "com.proj.db::base.folder";
public static final String TABLE_NAME = "`" + TABLE_NAME_NO_QUOTES + "`";
@Id
@Column(name = " ENTITY_ID ID ", nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ENTITY_SEQUENCE")
@GenericGenerator(name = "ENTITY_SEQUENCE",
strategy = ...SequenceStyleGenerator")
private Integer folderId;
...other fields{noformat}
Stack Trace:
{noformat}Caused by: java.lang.IllegalStateException: PostInitCallback queue could not be processed...
- PostInitCallbackEntry - Entity(com.backend.model.Folder) `sqmMultiTableMutationStrategy` interpretation
- PostInitCallbackEntry - Entity(com.backend.model.Folder) `sqmMultiTableInsertStrategy` interpretation
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.executePostInitCallbacks(MappingModelCreationProcess.java:144)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.execute(MappingModelCreationProcess.java:88)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.process(MappingModelCreationProcess.java:40)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:201)
at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:319)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:269)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1455)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:142)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
... 54 more
Suppressed: org.hibernate.HibernateException: Unable to parse object name: "com.proj.db::base.folder"
at org.hibernate.boot.model.relational.QualifiedNameParser.parse(QualifiedNameParser.java:149)
at org.hibernate.boot.model.relational.QualifiedNameParser.parse(QualifiedNameParser.java:199)
at org.hibernate.dialect.temptable.TemporaryTable.<init>(TemporaryTable.java:83)
at org.hibernate.dialect.temptable.TemporaryTable.createEntityTable(TemporaryTable.java:302)
at org.hibernate.dialect.H2Dialect.getFallbackSqmInsertStrategy(H2Dialect.java:693)
at org.hibernate.query.sqm.mutation.internal.SqmMultiTableMutationStrategyProviderStandard.createInsertStrategy(SqmMultiTableMutationStrategyProviderStandard.java:53)
at org.hibernate.persister.entity.AbstractEntityPersister.interpretSqmMultiTableInsertStrategy(AbstractEntityPersister.java:4807)
at org.hibernate.persister.entity.AbstractEntityPersister.lambda$prepareMappingModel$17(AbstractEntityPersister.java:4659)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess$PostInitCallbackEntry.process(MappingModelCreationProcess.java:246)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.executePostInitCallbacks(MappingModelCreationProcess.java:106)
... 64 more{noformat}
Additional Notes:
From what I can tell looking in the hibernate code the issue comes from {{org.hibernate.dialect.temptable.TemporaryTable }}constructor, which from version {{6.1.4}} has changed the way it parses the table name to use {{QualifiedNameParser }}which restricts the acceptable table names to the previously mentioned format: {{"schema.catalog.tableName"}}. Also this seems to ignore the physical naming strategy property.
This is a breaking change for our projects and probably many others.
Links:
Reported at: [https://discourse.hibernate.org/t/hibernate-6-issues-with-table-name/7763...]
PR to reproduce the issue: [https://github.com/hibernate/hibernate-test-case-templates/pull/276|https...]
( https://hibernate.atlassian.net/browse/HHH-16765#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16765#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:62413c2 )
2 years, 10 months
[JIRA] (HHH-16765) Hibernate 6 Cannot parse table name
by Culeafa Mihai (JIRA)
Culeafa Mihai ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNDhiMWQxNDM2... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16765?atlOrigin=eyJpIjoiNDhiMW... ) HHH-16765 ( https://hibernate.atlassian.net/browse/HHH-16765?atlOrigin=eyJpIjoiNDhiMW... ) Hibernate 6 Cannot parse table name ( https://hibernate.atlassian.net/browse/HHH-16765?atlOrigin=eyJpIjoiNDhiMW... )
Issue Type: Bug Affects Versions: 6.1.4, 6.1.5, 6.1.6, 6.1.7, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.2.4 Assignee: Unassigned Components: hibernate-core Created: 07/Jun/2023 04:29 AM Labels: JDK17 breaking-change Priority: Major Reporter: Culeafa Mihai ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... )
Entities using the annotations @GeneratedValue , @GenericGenerator }}and {{@SecondaryTable }}that have a table name not following the standard format of {{"schema.catalog.tableName" cannot be parsed regardless of physical-strategy property. Example table name: com.proj.db::base.folder. Adding quotes does not fix the issue.
This issues has appeared in versions later that 6.1.3 (last version without the issue).
Example Entity:
@Entity
@Table(name = Folder.TABLE_NAME)
@SecondaryTable(name = RelationView.TABLE_NAME, pkJoinColumns = @PrimaryKeyJoinColumn(name = "NODE"))
@JsonIgnoreProperties(ignoreUnknown = true)
public class Folder extends Entity<Folder, Integer> {
public static final String TABLE_NAME_NO_QUOTES = "com.proj.db::base.folder";
public static final String TABLE_NAME = "`" + TABLE_NAME_NO_QUOTES + "`";
@Id
@Column(name = "ENTITY_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ENTITY_SEQUENCE")
@GenericGenerator(name = "ENTITY_SEQUENCE",
strategy = ...SequenceStyleGenerator")
private Integer folderId;
...other fields
Stack Trace:
Caused by: java.lang.IllegalStateException: PostInitCallback queue could not be processed...
- PostInitCallbackEntry - Entity(com.backend.model.Folder) `sqmMultiTableMutationStrategy` interpretation
- PostInitCallbackEntry - Entity(com.backend.model.Folder) `sqmMultiTableInsertStrategy` interpretation
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.executePostInitCallbacks(MappingModelCreationProcess.java:144)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.execute(MappingModelCreationProcess.java:88)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.process(MappingModelCreationProcess.java:40)
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:201)
at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:319)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:269)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:431)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1455)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:142)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
... 54 more
Suppressed: org.hibernate.HibernateException: Unable to parse object name: "com.proj.db::base.folder"
at org.hibernate.boot.model.relational.QualifiedNameParser.parse(QualifiedNameParser.java:149)
at org.hibernate.boot.model.relational.QualifiedNameParser.parse(QualifiedNameParser.java:199)
at org.hibernate.dialect.temptable.TemporaryTable.<init>(TemporaryTable.java:83)
at org.hibernate.dialect.temptable.TemporaryTable.createEntityTable(TemporaryTable.java:302)
at org.hibernate.dialect.H2Dialect.getFallbackSqmInsertStrategy(H2Dialect.java:693)
at org.hibernate.query.sqm.mutation.internal.SqmMultiTableMutationStrategyProviderStandard.createInsertStrategy(SqmMultiTableMutationStrategyProviderStandard.java:53)
at org.hibernate.persister.entity.AbstractEntityPersister.interpretSqmMultiTableInsertStrategy(AbstractEntityPersister.java:4807)
at org.hibernate.persister.entity.AbstractEntityPersister.lambda$prepareMappingModel$17(AbstractEntityPersister.java:4659)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess$PostInitCallbackEntry.process(MappingModelCreationProcess.java:246)
at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.executePostInitCallbacks(MappingModelCreationProcess.java:106)
... 64 more
Additional Notes:
From what I can tell looking in the hibernate code the issue comes from org.hibernate.dialect.temptable.TemporaryTable }}constructor, which from version {{6.1.4 has changed the way it parses the table name to use QualifiedNameParser }}which restricts the acceptable table names to the previously mentioned format: {{"schema.catalog.tableName". Also this seems to ignore the physical naming strategy property.
This is a breaking change for our projects and probably many others.
Links:
Reported at: https://discourse.hibernate.org/t/hibernate-6-issues-with-table-name/7763
PR to reproduce the issue: https://github.com/hibernate/hibernate-test-case-templates/pull/276
( https://hibernate.atlassian.net/browse/HHH-16765#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16765#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:62413c2 )
2 years, 10 months