Hi Alexander, Thanks for reporting this. I will look at the reported exception and see if there is a workaround to this. I could probably add a case-sensitivity flag for the code-generator, or maybe there's another solution.
But case-sensitivity is a mine-field, and MySQL is the PHP of databases. It is really incredible that they have settings to (inconsistently) handle the reporting of table names in dictionary views, regardless of the actual casing! And it is also incredible, that the OS on which a MySQL instance is running, has an influence on the case-sensitivity of MySQL tables (but not columns, as far as I know!) In my opinion, your best bet is to choose a casing (upper, lower) in DDL and use back-ticks to enforce it, e.g. CREATE TABLE `MY_TABLE` ( `ID` INT, ... ); This will keep you from encountering other, non-jOOQ related issues. Cheers Lukas 2013/6/25 Alexander Ryzhov <[email protected]> > Hi, I am a new JOOQ user, and I a very excited about this library. I'd > like to thank all its developers for this great contibution to the Java > world. > > Now to the issue. I am using MySQL 5.1, which has a couple of settings > related to handling case sensitivity in object names: > > lower_case_file_system > lower_case_table_names > > Those settings are described > here<http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html>in > detail. > > In Windows, the default settings are: > lower_case_file_system=ON > lower_case_table_names=1 > > which means "the file-system is case-insensitive and all schema and table > names will be converted to lowercase". > > In order to make JOOQ work with my schema in Windows and Linux, I tried to > lower_case_table_names=2, which means "preserve the case but make > comparisons case-insensitive". > > This setting works as I want but it crashes JOOQ generation tool with the > following exception: > > SEVERE: Error while fetching tables > java.lang.NullPointerException > at > org.jooq.util.AbstractElementContainerDefinition.<init>(AbstractElementContainerDefinition.java:67) > at > org.jooq.util.AbstractTableDefinition.<init>(AbstractTableDefinition.java:64) > at > org.jooq.util.mysql.MySQLTableDefinition.<init>(MySQLTableDefinition.java:64) > at > org.jooq.util.mysql.MySQLDatabase.getTables0(MySQLDatabase.java:223) > at > org.jooq.util.AbstractDatabase.getTables(AbstractDatabase.java:433) > at > org.jooq.util.JavaGenerator.generateSchema(JavaGenerator.java:1568) > at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:179) > at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:170) > at org.jooq.util.GenerationTool.run(GenerationTo:291)va > at org.jooq.util.GenerationTool.main(GenerationTool.java:135) > at org.jooq.util.GenerationTool.main(GenerationTool.java:122) > > Using the debugger, I found that the cause of the problem is that > getSchema doesn't find schema name in the result for the query on schema > names: > > AbstractDatabase.java: > public final SchemaDefinition getSchema(String inputName) { > for (SchemaDefinition schema : getSchemata()) { > if (schema.getName().equals(inputName)) { > return schema; > } > } > return null; > } > > Note case-sensitive name comparison used in the loop. After further > investigation, I found that MySQL is returning lower-case schema name in > the following query made by JOOQ (my schema name is 'EMP', in upper case): > > select TABLE_SCHEMA > from INFORMATION_SCHEMA.TABLES > where TABLE_SCHEMA = 'EMP'; > > The result is: > > TABLE_SCHEMA > ------------------------- > emp > > > Interestingly enough, a slightly different query returns schema name in > upper case: > > select distinct TABLE_SCHEMA > from INFORMATION_SCHEMA.TABLES; > > TABLE_SCHEMA > ------------------------- > information_schemaEMPmysqlperformance_schema > It's really a mystery, I don't know why does MySQL change the case of > schema name depending on the WHERE clause, but the fact is that it crashes > JOOQ. > > As a workaround, I changed lower_case_table_names=0, meaning "preserve > case and make case-sensitive comparison". > > So, in short, I had to sacrifice case insensitivity in order make JOOQ > work. > > Regards, > Alexander > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
