3 Replies Latest reply on Jan 17, 2011 7:41 AM by Max Rydahl Andersen

    JPA Project - cannot resolve tables

    Claus Dreyer Newbie

      Hi,

       

      I have a simple project made with the 'JPA Project' wizard. My development setup is Eclipse 3.6 Helios, JBoss Tools 3.2.CR1 and MySQL 5.5.8. Everything is running on Windows.

       

      The problem is that I get the error Table "MyEntity" cannot be resolved

       

      The entity class MyEntity is a very simple test class. The corresponding table was created with a DDL file made by the JPA Tools -> Generate Tables from Entities... wizard.

       

      I have tried many things to get it to work. I finally made an entity class called lowercase (all of the letters are lower case), and suddenly it worked...

       

      It seems that the tools (I don't know if it is JBoss Tools or Dali) does a case sensitive comparison on the class name and table name. By default MySQL on Windows converts all table names to lower case. This is not the case for column names where lettercase is preserved. On Unix (and Mac I believe) lettercase is preserved by default by MySQL.

       

      MySQL has a global system variable called lower_case_table_names (see MySQL doc: Identifier Case Sensitivity). According to the MySQL documentation it can be set to 2 (instead of 1) and lettercase will be preserved on Windows. However, this has implications for your database statements which now must have the correct lettercase.

       

      I have tried to start MySQL with lower_case_table_names=2, then drop the existing database, re-create the database, run the DDL for my two simple classes mentioned above and then the tools work.

       

      I don't know if this issue should be classified as a bug or just filed on quirks related to MySQL.

       

      Kind regards,

      Claus