ScalaMetaDataSerializer incorrect placing of @Table annotation

Bug #655983 reported by Igor Rumiha on 2010-10-06
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released

Bug Description

The ScalaMetaDataSerializer creates a class and a companion object for each database table/object. The @Table annotation gets placed in front of the companion object, not the class, for example:

=== example code (extracted from a Scala REPL session)
import com.mysema.query.scala.sql._
import java.sql.{DriverManager, SQLException, Statement, Connection}
import com.mysema.query.types.path._
import com.mysema.query.sql._
import java.util.Arrays

val dbc = DriverManager.getConnection("jdbc:postgresql:dbname", "username", "password")
val namingStrategy = new DefaultNamingStrategy()
val serializer = new ScalaMetaDataSerializer("Q", namingStrategy)
val beanSerializer = new ScalaBeanSerializer()
val exporter = new MetaDataExporter("Q", "test", new File("target/gen"), namingStrategy, serializer, beanSerializer)

one of the generated classes looks like this:


object QFeature {
    def as(variable: String) = new QFeature(variable)

class QFeature(path: String) extends RelationalPathBase[QFeature](classOf[QFeature], path) {
    val description: StringPath = createString("description");

    val id: NumberPath[java.lang.Integer] = createNumber("id", classOf[java.lang.Integer]);


The @Table("feature") annotation should be in front of the class definition.
My suggestion would be to simply move the generation of the companion object definition (lines 62 - 64 inclusive in ScalaMetaDataSerializer.scala) below the class definition. That should do it.

Patch attached.

Igor Rumiha (igorrumiha) wrote :

Thanks for the bug report and patch. I didn't change the order of the companion object and class, but moved the annotations to the class.

Changed in querydsl:
importance: Undecided → High
status: New → Fix Committed

How does Querydsl SQL for Scala feel like? We don't yet use Scala much in our company, so critical feedback is welcome.

Igor Rumiha (igorrumiha) wrote :

I've only learned about it yesterday. In many ways it's similar to scala-query and squeryl but the main feature that sets querydsl apart from those is the ability to generate the data model from an existing database. That's a huge help for me as I am working on an evolution of an existing product with a quite complex database schema.
I'll have to explore the API a little bit more to give more useful comments.

Released in 2.0.2

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers