JPA 2.0 & MySQL are not respecting case sensitive table names

空扰寡人 提交于 2019-12-12 03:46:00

问题



I have a strange issue my ear project: I have put the correct annotations on my entity class:

@Entity
@Table(name = "PRODUCTS")

But when I deploy my application on glassfish 3.1.2.2, I find that JPA has created the tables with lowercase chars

I am using EclipseLink 2.4.1

Please Help me.


回答1:


I got the solution from Brian Vosburgh's comment: In the windows version of MySQL the names of table are set to lower case. On linux, by default, this configuration is disabled, and the tables'names set by JPA are applied to MySQL without modification.

To make it working on windows as like linux, add the line:

lower_case_table_names=0

Thank you for your help, specially Brian Vosburgh




回答2:


I found a property the makes all the difference. In the EclipseLink wizard (generate entities from tables), third page (Customize Defaults), I checked the "Always generate optional JPA annotations and DDL parameters" option. This option writes the below annotation in the Entity class:

@Table(name="TableName")

The correct table name letter case will be used.



来源:https://stackoverflow.com/questions/15247386/jpa-2-0-mysql-are-not-respecting-case-sensitive-table-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!