Domanda

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.

È stato utile?

Soluzione

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

Altri suggerimenti

Just change the constructor argument to a plain one:

_applicationType: Option[String] = None,

and introduce the val separately

@Transient val applicationType = _applicationType
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top