Hi,

We actually just fixed this issue a couple of days ago:
https://github.com/jOOQ/jOOQ/issues/3293

We suspect that a recent change in H2's information_schema implementation
has exposed this pre-existing bug in our jOOQ-Meta queries.

If you need the fix now, I suggest you check out jOOQ 3.4.0-SNAPSHOT from
GitHub and build your own.

The jOOQ 3.4.0 release is due in the next two weeks. Merges of this fix to
3.3.3 and 3.2.6 will be done after that.

Cheers
Lukas


2014-06-04 22:46 GMT+02:00 <[email protected]>:

> Hi all,
>
> Here is an excerpt from my schema:
>
> CREATE TABLE User (
> id INTEGER NOT NULL AUTO_INCREMENT,
> name VARCHAR(250) NOT NULL,
> email VARCHAR(250) NOT NULL,
> password VARCHAR(250) NOT NULL,
> PRIMARY KEY (id)
> );
>
> CREATE TABLE Tag (
> id INTEGER NOT NULL AUTO_INCREMENT,
> uid UUID NOT NULL,
> parent INTEGER DEFAULT NULL,
> user INTEGER NOT NULL,
> label VARCHAR(250) NULL,
> PRIMARY KEY (id),
> UNIQUE (user, label),
> UNIQUE (uid),
> FOREIGN KEY (parent) REFERENCES Tag (id),
> FOREIGN KEY (user) REFERENCES User (id),
> );
>
> CREATE TABLE TagReferer (
> tag INTEGER NOT NULL,
> constraint tt_tag FOREIGN KEY (tag) REFERENCES Tag (id)
> );
>
> The problem is that jooq generates the following foreign key for
> TagReferer:
>
> public class Keys {
> [...]
>     private static class UniqueKeys0 extends org.jooq.impl.AbstractKeys {
> [...]
>         public static final
> org.jooq.UniqueKey<hu.engard.expenses.generated.tables.records.TagRecord>
> CONSTRAINT_1 = createUniqueKey(hu.engard.expenses.generated.tables.Tag.TAG,
> hu.engard.expenses.generated.tables.Tag.TAG.ID);
> [...]
>     private static class ForeignKeys0 extends org.jooq.impl.AbstractKeys {
> [...]
>         public static final
> org.jooq.ForeignKey<hu.engard.expenses.generated.tables.records.TagrefererRecord,
> hu.engard.expenses.generated.tables.records.TagRecord> TT_TAG =
> createForeignKey(hu.engard.expenses.generated.Keys.CONSTRAINT_1,
> hu.engard.expenses.generated.tables.Tagreferer.TAGREFERER, 
> *hu.engard.expenses.generated.tables.Tagreferer.TAGREFERER.TAG,
> hu.engard.expenses.generated.tables.Tagreferer.TAGREFERER.TAG*);
>     }
> }
>
> Please notice the duplicated ...Tagreferer.TAGREFERER.TAG in the TT_TAG.
> This results in exceptions when I am joining the two tables with onKey()
> method.
>
> If I remove any of the indexes from the Tag table (e.g., remove the UNIQUE
> (uid) index), then the problem disappears, and the generated TT_TAG foreign
> key looks like:
>
>         public static final
> org.jooq.ForeignKey<hu.engard.expenses.generated.tables.records.TagrefererRecord,
> hu.engard.expenses.generated.tables.records.TagRecord> TT_TAG =
> createForeignKey(hu.engard.expenses.generated.Keys.CONSTRAINT_1,
> hu.engard.expenses.generated.tables.Tagreferer.TAGREFERER,
> *hu.engard.expenses.generated.tables.Tagreferer.TAGREFERER.TAG*);
>
> What can be the problem, and the solution? Jooq version 3.2.2, H2 database
> version 1.3.174. codegen.xml snippet:
>
>     <database>
>       <name>org.jooq.util.h2.H2Database</name>
>       <includes>.*</includes>
>       <excludes></excludes>
>       <inputSchema>PUBLIC</inputSchema>
>     </database>
>     <generate>
>       <pojos>true</pojos>
>       <interfaces>true</interfaces>
>       <daos>true</daos>
>       <navigationMethods>true</navigationMethods>
>     </generate>
>
> Thanks,
> Ferenc
>
> --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to