Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with JPA, EclipseLink and case sensitive mysql

My application is working fine in a Windows environment, but when I'm trying to test in a linux server, I have a problem with the JPA EclipseLink sql generated. I created all my tables in lower case, but when I look in the logs, I see something like that, all in upper case:

INSERT INTO PFC(ID, ALUMN,PROPOSED_ID) VALUES (?, ?, ?)

mixed with others like this (sequences) in lower case:

INSERT INTO buzonmensajes (mensajeid, buzonid) VALUES (?, ?)
        bind => [27, 1]

and of course, everything goes wrong, server didn't find the uppercase tables, etc..

We use orm.xml to define all the database actions (queries,entities, etc..) and everything it's in lowercase...

I know that there are a Mysql paramater to change these behaviour, but unfortunately I'm not allowed to change it. My problem is that I need to tell to JPA to create all the querys and insert statmets with the table name in lower case

like image 775
Aitor Avatar asked Sep 12 '11 19:09

Aitor


People also ask

How do I stop case sensitive in MySQL?

Another way for case-insensitive matching is to use a different “collation”. The default collations used by SQL Server and MySQL do not distinguish between upper and lower case letters—they are case-insensitive by default.

Why MySQL is not case sensitive?

Table names are stored in lowercase on disk and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.

Is like case-insensitive MySQL?

MySQL's like should be case-insensitive by default.


1 Answers

The issue is likely occurring because you are allowing EclipseLink to default some of the names. If you specify the names using the case of your database EclipseLink should use those cases by default.

If you find that is not working you can always enforce case by using delimited identifiers using the '\"' pattern : @Table("\"pfc\"") but this should not be required.

What version of EclipseLink are you using?

like image 168
Gordon Yorke Avatar answered Sep 26 '22 03:09

Gordon Yorke