Hi Kiru, I'm sorry for the round trip. I must have missed some detail in your original mail. What you really want is a generic record reference of the primary key record type in both the primary key MyUuid and in all referencing foreign key MyUuid.
There had actually been similar ideas in the past, I believe on this mailing list, and perhaps even as GitHub issues (although I cannot seem to find them). Such a type system enhancement would allow for enforcing JOIN predicate comparisons to compile only for matching primary key / foreign key or foreign key / foreign key pairs. A similar issue is this one: https://github.com/jOOQ/jOOQ/issues/2574 But I'll create a new one to be sure we won't forget: https://github.com/jOOQ/jOOQ/issues/6124 Certainly a very good idea. I don't think there's an easy workaround right now to achieve the same. 2017-04-21 14:11 GMT+02:00 Kirusanth Poopalasingam <[email protected]>: > Hi Lukas, > > This is the configuration and converter: > > // skipped jdbc > > Converter<UUID, MyUuid> uuidToMyUuid = Converter.of( > UUID.class, > MyUuid.class, > MyUuid::create, > myUuid -> UUID.fromString(myUuid.asString()) > ); > > Configuration configuration = > new Configuration() > .withJdbc(jdbc) > .withGenerator(new Generator() > .withStrategy(new Strategy() > .withName(DefaultGeneratorStrategy.class.getName())) > .withDatabase(new Database() > .withIncludes(".*") > .withExcludes("") > .withInputSchema("public") > .withCustomTypes( > new CustomType() > .withName(uuidToMyUuid.toType().getName()) > .withType(uuidToMyUuid.toType().getName()) > .withConverter(uuidToMyUuid.getClass().getName()) > ) > .withForcedTypes( > new ForcedType() > .withName(uuidToMyUuid.toType().getName()) > .withTypes("UUID") > ) > ) > .withGenerate(new Generate() > .withDaos(false) > .withPojos(false) > .withRecords(true) > .withInterfaces(false) > ) > .withTarget(new Target() > .withPackageName("") > .withDirectory("../src/main/java")) > ); > > GenerationTool.generate(configuration); > > > > > Thanks, > Kiru > > > Am Freitag, 21. April 2017 12:19:15 UTC+2 schrieb Lukas Eder: >> >> Hi Kiru, >> >> Thanks for your nice words. >> >> It's perfectly possible to register converters that use generics, but >> perhaps you haven't configured the code generator correctly? Can you please >> post your converter and your code generator configuration? >> >> Thanks, >> Lukas >> >> 2017-04-21 12:08 GMT+02:00 Kirusanth Poopalasingam <[email protected]>: >> >>> Hello Lukas, >>> >>> First, thank you for creating jOOQ ( and giving a serious alternative to >>> JPA / Hibernate). We use jOOQ heavily in our projects. >>> >>> For primary and foreign keys, we have a custom UUID class with generics >>> like MyUuid<T> and added a Converter from java.util.UUID to our MyUuid. >>> >>> With the generic-MyUuid, you get an additional type safety. Now the >>> problem is, that the converter does not respect the generic type and >>> generates Methods like: >>> >>> public class MyTableRecord ... { >>> // ... >>> public void setId(MyUuid value) { // better: >>> setId(MyUuid<MyTableRecord> value) >>> setValue(0, value); >>> } >>> >>> >>> public void setOtherFk(MyUuid value) { // better: >>> setOtherFk(MyUuid<OtherRecord> >>> value) >>> setValue(6, value); >>> } >>> // ... >>> } >>> >>> >>> >>> Is there a way to hook into the code-generation process to set the >>> generic types-correctly. >>> >>> ( Tested with jOOQ 3.9.1 and PG 9.1) >>> >>> Thank you, >>> Kiru >>> >>> -- >>> 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. > -- 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.
