Entities containing field "rank" cannot be updated
Description
Activity

Andrea Boriero August 12, 2020 at 2:59 PM
yes please and attach also a reproducer, it is difficult to understand what is causing the issue with only the strack trace.

Sergiu Hlihor August 12, 2020 at 2:52 PM
I just did that but it crashed with the stacktrace from above. Shall I open another ticket?

Andrea Boriero August 12, 2020 at 2:37 PM
Hi , you have to enable auto quoting of keywords setting hibernate.auto_quote_keyword
to true
Nathan Xu August 11, 2020 at 8:28 PMEdited
Thanks. It would be great to attach your entity source code to help others to reproduce the issue. Is the ‘rank’ usage the root cause of the issue, btw?

Sergiu Hlihor August 11, 2020 at 8:19 PMEdited
I have just tried to add the property and now it crashes with:
Exception in thread "main" org.hibernate.DuplicateMappingException: Table [MyEntity] contains logical column name [owner_id] referring to multiple physical column names: [owner_id
], [owner_id]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl$TableColumnNameBinding.bindLogicalToPhysical(InFlightMetadataCollectorImpl.java:920)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl$TableColumnNameBinding.addBinding(InFlightMetadataCollectorImpl.java:908)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.addColumnNameBinding(InFlightMetadataCollectorImpl.java:979)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.addColumnNameBinding(InFlightMetadataCollectorImpl.java:960)
at org.hibernate.cfg.Ejb3JoinColumn.addColumnBinding(Ejb3JoinColumn.java:788)
at org.hibernate.cfg.Ejb3Column.linkWithValue(Ejb3Column.java:371)
at org.hibernate.cfg.annotations.TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit(TableBinder.java:719)
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:649)
at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1709)
at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:940)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:856)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:795)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:53)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1693)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1661)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:286)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1224)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1255)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
Where owner_id is actually the id of another entity inside MyEntity annotated with @NotNull and @ManyToOne
I also use Hibernate Envers
I have a an entity containing a field called “rank“ . This worked perfectly fine with MySQL 5.6. Now in MySQL 8, since this is a keyword, it fails to update the field.
Tested configurations were:
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect" />
or no dialect whatsoever.
Database is MySQL 8.0.20, Percona flavor + HikariCP
Would have expected that by choosing the correct dialect, the fields are escaped automatically.