mysema/querydsl — Issue #86: cannot compile generated scala code
Author: khoran
Created: 2012-01-26 01:20:12+00:00
State: open

After generating scala code from my database schema I get 94 compile errors. There are really only two different types of errors.
The first is this:

[ERROR] /home/khoran/development/web_services/target/generated-sources/scala/net/globalrecordings/davical/schema/PgLargeobject.scala:14: error: not found: type byte
[INFO] var data: Array[byte] = _
[INFO] ^
[ERROR] /home/khoran/development/web_services/target/generated-sources/scala/net/globalrecordings/davical/schema/PgToast11454.scala:14: error: not found: type byte
[INFO] var chunkData: Array[byte] = _
[INFO] ^
[ERROR] /home/khoran/development/web_services/target/generated-sources/scala/net/globalrecordings/davical/schema/PgToast11459.scala:14: error: not found: type byte
[INFO] var chunkData: Array[byte] = _
[INFO] ^
[ERROR] /home/khoran/development/web_services/target/generated-sources/scala/net/globalrecordings/davical/schema/PgToast11464.scala:14: error: not found: type byte
[INFO] var chunkData: Array[byte] = _

This looks like its getting java and scala confused, as scala should be using "Byte". The second error looks like:

[ERROR] /home/khoran/development/web_services/target/generated-sources/scala/net/globalrecordings/davical/schema/QCaldavData.scala:56: error: not found: value Arrays
[INFO] val _caldavExists: ForeignKey[CalendarItem] = createInvForeignKey(Arrays.asList(userNo, davName), Arrays.asList("user_no", "dav_name"))

Which looks like it just forgot to import the "Arrays" class from java. Here is my relevant maven config:

com.mysema.querydsl
querydsl-maven-plugin
${querydsl.version}

export

org.postgresql.Driver
jdbc:postgresql://postgres.us.grn/davical

davical_app
xxxxx

net.globalrecordings.davical.schema

${project.basedir}/target/generated-sources/scala
true
true

postgresql
postgresql
9.0-801.jdbc4

com.mysema.querydsl
querydsl-scala
${querydsl.version}

org.scala-lang
scala-library
${scala.version}

I can actually do without all the pg_* stuff, which leaves the Arrays.asList errors. After further investigation, this is actually two problems. If I manually add "import java.util.Arrays', then that error goes away, but it turns out that neither "createInvForeignKey" nor "createInvForeignKey" is defined for lists. This was easy enough to fix by adding the two functions into RelationalPathImpl:

def createForeignKey[F](local: JList[Path[_]], foreign: JList[String]) = {
val foreignKey = new ForeignKey[F](this, local, foreign)
foreignKeys.add(foreignKey)
foreignKey
}
def createInvForeignKey[F](local: JList[Path[_]], foreign: JList[String]) = {
val foreignKey = new ForeignKey[F](this, local, foreign)
inverseForeignKeys.add(foreignKey)
foreignKey
}
since ForeignKey is defined for lists. The call still needs a cast to work though, not sure about that. I haven't actually used this to see if its correct, I just got it to compile.

Another error I found after this is :

[INFO] Compiling 157 source files to /home/khoran/development/web_services/target/classes at 1327527351165
[ERROR] /home/khoran/development/web_services/src/main/scala/net/globalrecordings/davical/schema/QRruleParts.scala:42: error: overriding lazy value count in trait SimpleExpression of type com.mysema.query.scala.NumberExpression[java.lang
.Long];
[INFO] value count needs `override' modifier
[INFO] val count = createNumber[Integer]("count")
[INFO] ^

In this case the variable "count" is actually already defined in an inherited class ("SimpleExpression"). Not sure how to fix this one.

I'm using version 2.3.0. Thanks for any help.