我不明白,Spring JPA是否依赖于Hibernate?如果我使用Spring JPA,我应该有任何Hibernate配置吗?
我使用Spring JPA访问数据库,我已经使用Java注释配置了映射,并且我的一个字段按以下方式注释:
private String annotationClusterColorVerify;
@Basic
@Column(name = "annotationClusterColorVerify")
public String getAnnotationClusterColorVerify() {
return annotationClusterColorVerify;
}
public void setAnnotationClusterColorVerify(String annotationClusterColorVerify) {
this.annotationClusterColorVerify = annotationClusterColorVerify;
}
在数据库中,它具有以下声明:
annotationClusterColorVerify TEXT;
尽管如此,我在初始化时遇到以下错误:
2016-03-22 15:57:12.969 INFO 15216 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-03-22 15:57:13.019 INFO 15216 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2016-03-22 15:57:13.124 INFO 15216 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2016-03-22 15:57:14.003 INFO 15216 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-03-22 15:57:14.179 WARN 15216 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1054, SQLState: 42S22
2016-03-22 15:57:14.179 ERROR 15216 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : Unknown column 'ct0_.annotation_cluster_color_verify' in 'field list'
2016-03-22 15:57:14.184 WARN 15216 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 1054, SQLState: 42S22
2016-03-22 15:57:14.184 WARN 15216 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : Unknown column 'ct0_.annotation_cluster_color_verify' in 'field list'
2016-03-22 15:57:14.193 ERROR 15216 --- [ main] o.s.boot.SpringApplication : Application startup failed
显然,它决定以某种方式使用下划线版本的列名。
为什么以及如何解决?
请注意,我正在尝试避免使用任何配置文件。目前我只有application.properties
,我只描述了数据库:
spring.datasource.url=MYURL
spring.datasource.username=MYUSER
spring.datasource.password=MYPWD
spring.datasource.driver-class-name=com.mysql.jdbc.Driver