質問

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.

役に立ちましたか?

解決

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

他のヒント

Just change the constructor argument to a plain one:

_applicationType: Option[String] = None,

and introduce the val separately

@Transient val applicationType = _applicationType
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top