我使用 Hibernate + Spring JPA 和 Mysql 5.7 作为 DBMS。我想使用一些保留关键字作为列名,为此我准备了:
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
有些列有自定义定义,例如:
@CreatedDate
@Column(updatable = false, columnDefinition = "DATETIME(6)")
private LocalDateTime createdDate;
不幸的是,Hibernate 将其翻译为:
`created_date` `DATETIME(6)`
代替
`created_date` DATETIME(6)
我在 Hibernate JIRA 上开了一个问题 (JIRA) ;我想知道是否有可以同时使用的解决方法。
最佳答案
感谢 Hibernate 人员,我找到了正确的解决方案:
为了避免引用列定义,有一个特定的设置:
spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definitions=true
不幸的是,现在,它向后工作 (see this bug):所以如果您想跳过列定义,您必须将其设置为 false。
关于mysql - Hibernate 5.0.12 错误的列定义与 Mysql 5.7 转义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44363937/