实体类名转换成带下划线的SQL表名 [英] Entity Class name is transformed into SQL table name with underscores

查看:33
本文介绍了实体类名转换成带下划线的SQL表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义了以下实体:

@Entity
@Table(name = "EmailTemplate")
public class EmailTemplate {

尽管有表注释,我还是收到 java.sql.SQLException: Invalid object name 'email_template'.如何防止将 EmailTemplate 等实体类转换为 email_template 表名?

Despite the table annotation, I receive java.sql.SQLException: Invalid object name 'email_template'. How can I prevent an entity class such as EmailTemplate being transformed into email_template table name?

我正在使用 Spring Boot:启动 JPA.从我的 build.gradle 文件中,

I'm using Spring Boot: start JPA. From my build.gradle file,

compile("org.springframework.boot:spring-boot-starter-data-jpa")

推荐答案

Spring 默认使用 org.springframework.boot.orm.jpa.SpringNamingStrategy 用下划线分割驼峰命名法.尝试在 application.properties 中设置 spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy.查看这个this 了解更多信息.

Spring by default uses org.springframework.boot.orm.jpa.SpringNamingStrategy which splits camel case names with underscore. Try setting spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy in application.properties. Check out this and this for more info.

这篇关于实体类名转换成带下划线的SQL表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆