Hi Lukas,

Thanks for your prompt reply.

First of all, I can confirm that I am indeed using the latest versions of 
jOOQ and H2, which I understand to be 3.2.3 and 1.3.175 respectively.

I've observed the issue for all tables containing a primary key, so this 
simple table is enough to demonstrate it:

CREATE TABLE consultant (
  ConsultantID int unsigned NOT NULL auto_increment,
  Name varchar NOT NULL,
  JobTitle varchar NOT NULL default '',
  IsDeleted tinyint unsigned NOT NULL default 0,
  PRIMARY KEY (ConsultantID)
);

My H2 database connection URL is: 
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;IGNORECASE=true

After a little bit of experimentation with the query you've provided, I 
think I've seen what's causing the problem.  If I run this query using the 
connection described my the above URL then it prints the following results:

  PUBLIC, CONSULTANT, CONSULTANTID, CONSTRAINT_1

However, the DB connection URL we were intending to use for the application 
includes MySQL compatibility mode.  This is because the schema was 
originally designed for MySQL but it's been ported over to run on H2.  With 
MySQL compatibility mode, the query yields the following:

  public,consultant,CONSULTANTID,constraint_1

Without compatibility mode, the PK is found correctly because the results 
come in upper case and therefore a Record is generated that inherits from 
org.jooq.impl.UpdatableRecordImpl as desired.  

Regards,

Adam


On Tuesday, 11 February 2014 17:36:34 UTC, Adam wrote:
>
> Hi,
>
> I've been experimenting with jOOQ and, first of all, I have to say I'm 
> very impressed so far.  There just seems to be one snag that I've 
> encountered regarding using H2's in-memory database alongside the jOOQ code 
> generator, in that it only generates org.jooq.impl.TableRecordImplclasses for 
> all tables rather than updatable records.
>
> The output from the code generator prints things like this:
>
> Feb 11, 2014 5:16:54 PM org.jooq.util.DefaultRelations info
> INFO: Ignoring primary key     : constraint_4(column unavailable)
> Feb 11, 2014 5:16:54 PM org.jooq.util.DefaultRelations info
> INFO: Ignoring primary key     : constraint_47(column unavailable)
>
> On closer inspection, it seems that the column is unavailable because the 
> code in org.jooq.util.h2.H2Database#loadPrimaryKeys is failing to extract 
> the primary key ColumnDefinition from its table by column name:
>
> 1           TableDefinition table = getTable(schema, tableName);
> 2           if (table != null) {
> 3               String[] columnNames = columnList.split("[,]+");
> 4
> 5               for (String columnName : columnNames) {
> 6                   relations.addPrimaryKey(primaryKey, 
> table.getColumn(columnName));
> 7               }
> 8           }
>
> The column name is coming in upper case but this doesn't agree with the 
> TableDefinition.  If I change the call to table.getColumn(columnName)(line 6 
> above) to be table.getColumn(columnName, 
> true) then it works perfectly and generates updatable table records as 
> I'd expect.
>
> I've had to extend the H2Database class and override the 
> loadPrimaryKeysmethod to fix this, but, given that nobody else seems to have 
> this problem, 
> I can't help feeling I'm missing something and there must be a better way 
> to handle this case-sensitivity issue.  Is there a less cumbersome way to 
> get code generation to work with H2 or is this actually a bug?
>
> Many thanks,
>
> Adam
>
>

-- 
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.

Reply via email to