This is a follow-up of the issue 10802. https://hibernate.atlassian.net/browse/HHH-10802
Test case
pom.xml {code:xml} <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging>
<name>demo</name> <description>Demo project for Spring Boot</description>
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
<properties> <hibernate.version>5.2.2.Final</hibernate.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties>
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
</project>
{code}
application.properties {code} #Database configuration spring.datasource.url: jdbc:postgresql://localhost:5432/postgres spring.datasource.driverClassName: org.postgresql.Driver spring.datasource.username: postgres spring.datasource.password: postgres spring.datasource.platform: postgresql spring.datasource.continue-on-error: false
spring.jpa.properties.hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.format_sql: true spring.jpa.generate-ddl: true spring.jpa.hibernate.ddl-auto: update spring.jpa.properties.hibernate.implicit_naming_strategy: default spring.jpa.hibernate.naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.auto_quote_keyword: true spring.jpa.show-sql: false {code}
Entity: Match.java {code:java} package com.example.model;
import java.io.Serializable; import java.util.Map; import java.util.TreeMap;
import javax.persistence.CollectionTable; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id;
@Entity public class Match implements Serializable { private static final long serialVersionUID = 795832280311186376L; @Id private Long id;
@ElementCollection(fetch = FetchType.EAGER) @CollectionTable private Map<Integer, Integer> awayTeamGoalTimeline = new TreeMap<>(); } {code}
Spring boot app entry point - DemoApplication.java
{code:java} package com.example;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication public class DemoApplication {
public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } } {code}
Steps 1. Start the application so that the schema is created. 2. Start the application once again, it crashes upon starting with
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Attempt to resolve foreign key metadata from JDBC metadata failed to find column mappings for foreign key named [fk38far8ndkwu15myx333actku7] at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl$ForeignKeyBuilderImpl.build(InformationExtractorJdbcDatabaseMetaDataImpl.java:727) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl$ForeignKeyBuilderImpl.build(InformationExtractorJdbcDatabaseMetaDataImpl.java:708) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getForeignKeys(InformationExtractorJdbcDatabaseMetaDataImpl.java:691) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.extract.internal.TableInformationImpl.foreignKeys(TableInformationImpl.java:88) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.extract.internal.TableInformationImpl.getForeignKey(TableInformationImpl.java:99) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.findMatchingForeignKey(SchemaMigratorImpl.java:529) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applyForeignKeys(SchemaMigratorImpl.java:505) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.performMigration(SchemaMigratorImpl.java:314) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:136) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:109) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:176) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:65) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:307) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:490) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:878) ~[hibernate-core-5.2.2.Final.jar:5.2.2.Final] ... 21 common frames omitted
From my point of view it has to have something in common with auto quoting key words set to {{true}}. I use PostgreSQL database. |
|