Ignoring a field in entity

18 views
Skip to first unread message

Pavel Penkov

unread,
Nov 5, 2014, 5:35:52 AM11/5/14
to squ...@googlegroups.com
I have an entity declared as follows

case class Snippet(id: Long,
                    name
: String,
                    text
: String,
                   
@Column("created_at") createdAt: Date,
                   
@Column("user_id") userId: Option[Long],
                   
@Transient author: Option[User]
) extends KeyedEntity[Long] {

 
def this() = this(0, "", "", new Date(), Some(0), Some(new User()))
}

Supposedly Squeryl won't map `author` field but it still fails with `java.lang.RuntimeException: field type models.squeryl.User is not supported`. I'm using Squeryl version 0.9.5-6.

David Whittaker

unread,
Nov 5, 2014, 1:45:07 PM11/5/14
to squ...@googlegroups.com
I think I noticed that this was answered on SO, but for posterity the problem is that scalac will only apply the annotation to the constructor argument by default, and you need it on the generated field.  The fix is to use (the very ugly) @(Transient @field) instead of @Transient.

--
You received this message because you are subscribed to the Google Groups "Squeryl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to squeryl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages