Hello!I'm currently experimenting with jooq together with scala.Unfortunately there seem to be many rough edges in everyday usage.Just some that I stumpled upon:- DSL.row function not usable from scala due to a known limitation of java interop with Object... vararg in scala.
- Missing first class support for scala types makes certain situations quite cumbersome.
- ResultQuery fetchInto and scala classes don't work together.
Are there any further plans to improve scala support?
--
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/topic/jooq-user/IQ4j8glws9s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Lukas!When using DSL.row with anything different then Field parameters, compilation fails with an "ambiguous reference to overloaded definition" error.For example this code fails:row(1, 2)The reason seems to be that the scala compiler can't find out which of the row methods is most specific.
Sorry, saying ResultQuery fetchInto doesn't work with scala classes was too generic.It doesn't work with case classes, which was the paradigm I wanted to use.
case class BookCase(id: Int,authorId: Int,title: String)case class BookCaseWithConstructorProperties @ConstructorProperties(Array("id", "authorId", "title")) (id: Int,authorId: Int,title: String)
--
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/topic/jooq-user/IQ4j8glws9s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Lukas,sorry for my late answer. Unfortunately I've been quite busy during the last days.
I suppose you already found out how the internals of case classes look like.Thanks for your great efforts and investigations!
Hopefully I will find some time to get another look on scala and jOOQ the next days.
If so, I will keep you posted.
Maybe we we'll also see each other on the Vienna Scala & Database jOOQ special edition on April, 7th.
Hello there. I'm chiming in on this thread 10 months later.I'm about to begin a new project with Play Framework and Scala and would like to use jOOQ over Slick if I can. Have there been any significant updates in either documentation or Scala integration that Scala users might find helpful since this was originally posted in March 20, 2014?
Any success stories of Scala users going to production with jOOQ?
I prefer the jOOQ paradigm but am nervous about edge cases I may run into down the line.
class StringOptionConverter extends Converter[String, Option[String]] {
override def from(t : String) : Option[String] =
if (t == null)
None
else
Some(t)
override def to(u : Option[String]) : String =
u match {
case None => null
case Some(s) => s
}
override def fromType : Class[String] = classOf[String]
override def toType : Class[Option[String]] = classOf[Option[String]]
}
<customTypes>
<customType>
<name>Option[String]</name>
<type>scala.Option<String></type>
<converter>org.jooq.scala.StringOptionConverter</converter>
</customType>
</customTypes>
<forcedTypes>
<forcedType>
<name>Option[String]</name>
<expression>.*\.first_name</expression>
</forcedType>
</forcedTypes>
class IntConverter extends Converter[java.lang.Integer, Int] {
override def from(t : java.lang.Integer) : Int = t.intValue()
override def to(u : Int) : java.lang.Integer = java.lang.Integer.valueOf(u)
override def fromType : Class[java.lang.Integer] = classOf[java.lang.Integer]
override def toType : Class[Int] = classOf[Int]
}
Lukas,Thanks so much for your prompt and thorough response.I agree with your position on Scala Options and SQL Nulls. This isn't a big deal since my Scala case classes simply don't have to use Option[String] for their types.The most important thing I care about is workflow and productivity. My dream is to be able to follow the following workflow:(1) Thoughtfully design my RDBMS and write out my DDL SQL for FlyWay to execute.(2) Apply it to Postgres(3) Run the jOOQ Code Generator(4) All my POJOs, most of my data access code, and the corresponding unit tests are now written
I probably don't have the time but if I were to write the Scala generator, can you share any thoughts you have about the best approach? Based on a cursory code review, it looks like this would be as simple as writing a ScalaGenerator.java class that's modeled on the JavaGenerator.java at https://github.com/jOOQ/jOOQ/blob/master/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java.
Also, when I previously worked with jOOQ, I found that I would have liked to have had jOOQ auto-generate my unit tests for me as well (although in theory, why would you ever need auto-generated unit tests if the code itself is auto-generated). I wound up spending a lot of my time writing DAOs and their corresponding unit tests,
and it would have been nice if I could have just auto-generated a stock DAO and then modified it from there. Do you see unit test generation as "in scope" for the code generator?
As a native enhancement or a "custom extension"?Anyway, the good news is it sounds like full-blown Scala support in jOOQ isn't too far off (either in time or in amount of work to be done). While Slick is the most popular Scala library for ORM, I find the "idiomatic Scala to SQL" thought process quite awkward and opaque in some cases, even if it's intuitively easy to pick up.