Hi Lukas,

ah, ok, I didn't even know that scala.Long is not nullable (makes sense of
course, it's an AnyVal); I haven't seen a null is Scala for a very long
time :-) Of course, support for Option-like types would be great but I can
see the problems.

So I'm wondering a bit about the advantages of the ScalaGenerator. I
haven't really looked into the generated files but the only difference I
can see now are longer compile times thanks to Scala :-D ;-) My project is
working as before, I didn't need to change a single line of code (except
for the bugs in the generated code of course).

Regards
Julian


2015-04-23 18:28 GMT+02:00 Lukas Eder <[email protected]>:

> Hello Julian,
>
> Thank you very much for your valuable feedback! I'll comment inline...
>
> 2015-04-23 11:32 GMT+02:00 Julian Backes <[email protected]>:
>
>> Hi all,
>>
>> I just tried the new ScalaGenerator and wanted to give some feedback. I
>> only added <name>org.jooq.util.ScalaGenerator</name> to the <generator> tag
>> in my xml file. I don't know if that suffices.
>>
>
> Yes, that's enough. The updated manual for jOOQ 3.6 is still pending.
> There will be a section dedicated to the ScalaGenerator.
>
>
>>  The generator still logs "INFORMATION: Generating DAO           :
>> FoldersDao.java" although a .scala file is generated :-)
>>
>
> Nice catch. This should be easy to fix:
> https://github.com/jOOQ/jOOQ/issues/4225
>
>
>> - I have columns named "type" which is a reserved word in scala. I needed
>> to replace all occurrences of type with `type` since the generator does not
>> escape such identifiers
>>
>
> Absolutely! https://github.com/jOOQ/jOOQ/issues/4227
>
>
>> - The ScalaGenerator still uses Java types like java.lang.Long instead of
>> scala.Long, Java List etc.; is this intended?
>>
>
> Yes. There are two issues here:
>
> 1. scala.Long is not nullable, so it doesn't fit into jOOQ's general
> Record model. We have a pending feature request to support Option (or Java
> Optional) in the code generator (https://github.com/jOOQ/jOOQ/issues/3231),
> but we haven't thought this through entirely yet. There are quite a few
> edge-cases, where an Option type will subtly break jOOQ API - e.g. when
> using functions, grouping sets, outer join, union, and many more. We're
> closely observing the Slick mailing list and I'm personally convinced that
> Slick's using Option for database queries is an impediment to Slick
> adoption.
> 2. Java List has to be used in some generated artefacts because we want to
> implement / extend org.jooq.* API, e.g. org.jooq.Schema.getTables(). I
> suspect we cannot work around that. Or did you have a different List usage
> in mind?
>
>
>> - Two warning from the scala compiler (i don't know if this is really a
>> problem):
>> [warn] /xxx/models/Public.scala:13: imported `Sequences' is permanently
>> hidden by definition of object Sequences in package models
>> [warn] import models.Sequences
>> [warn] /xxx/models/Sequences.scala:11: imported `Public' is permanently
>> hidden by definition of object Public in package models
>> [warn] import models.Public
>>
>
> Hmm, I had thought that we had gotten rid of all of these, but I can
> confirm we haven't. Thanks!
> https://github.com/jOOQ/jOOQ/issues/4229
>
>
>> After having replaced the reserved keywords, everything seems to be
>> working as before although I expected/hoped for more Scala types from a
>> ScalaGenerator ;-)
>>
>
> Well, you *can* use those types when you implement your own Converters or
> Bindings. It's actually rather easy, but you will see quickly that it will
> become nasty quite quickly, as the API guarantee of a non-nullable Int type
> will be broken as soon as you outer join a table, which would technically
> turn a Field[Int] into a Field[Option[Int]] - except that you won't get
> that Option into your record type.
>
> You could use Converters to generate Option[Int] for all Integer columns,
> though - even if they're NOT NULL.
>
> Cheers - and thanks again for all your feedback!
> Lukas
>
> --
> 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