I don't think you can override anything in the code generator. This must be
implemented in jOOQ-meta (i.e. as a data type). If you'd like to continue
trying, you could extend your jOOQ-meta Database in order to manage the
DataTypeDefinition of your primary key / foreign key columns. This might
work at least for non-composite keys.

Let me know if you need some additional pointers.
Lukas

2017-04-21 16:29 GMT+02:00 Poopalasingam Kirusanth <[email protected]>:

> Hi Lukas,
>
> Thank you for creating the issue, I'll track it further.
>
> I tried to overwrite the JavaGenerator.generateRecordGetter() but you
> there you don't have access to the TableDefiniton.
>
> Did the following hack to get it working, but this only works for the
> primary key. For the FK, I don't know how to get the target record class
> name:
>
> https://gist.github.com/kiru/aede8ee04cab7528fe54ddadb606e3db
>
> Thanks,
> Kiru
>
>
>
>
>
> 2017-04-21 14:36 GMT+02:00 Lukas Eder <[email protected]>:
>
>> 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 a topic in the
>> Google Groups "jOOQ User Group" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/jooq-user/53RZqoewa3g/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Mit freundlichen GrĂ¼ssen
> *K*irusanth *P*oopalasingam
>
> --
> 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