Search code examples
scalaannotationssqueryl

Squeryl doesn't detect annotated val constructor argument as transient


I have a class with a constructor parameter like this:

@Transient val applicationType: Option[String] = None,

However, Squeryl doesn't notice the @Transient annotation, and still tries to read the value of this field from the database. But there is no such field in the database.

My investigations so far have showed that, as I suspected, Squeryl only looks at the method and field annotations, whereas the annotation is only placed by the Scala compiler on the argument of the constructor (I can see this with javap).

So how can I fix this?

The class is not a case class because I'm extending a case class, and case classes shouldn't extend other case classes.


Solution

  • You can also tell scalac that you want the annotation to appear on the field. See this answer for the proper syntax.