ScalaNovice
unread,Mar 28, 2012, 3:01:02 PM3/28/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to orbroker
I have 2 tables: entries and photographs. An entry is allowed to
have no photos or N number of photos. They're foreign keyed the way
you would expect. Here's my classes and extractors:
case class Entry(
id: Option[Long],
name: String,
description: String,
date_added: java.util.Date,
total_files: Int,
categories: List[String],
files: Seq[Photo]
)
case class Photo(id: Long, name: String)
object EntryExtractor extends JoinExtractor[Entry] {
val key = Set("id")
def extract(row: Row, join: Join) = {
new Entry(
row.bigInt("id"),
row.string("name").get,
row.string("description").get,
row.timestamp("date_added").get,
row.integer("file_count").get,
row.array[String]("categories").get.toList,
join.extractSeq(PhotoExtractor)
)
}
}
object PhotoExtractor extends RowExtractor[Photo] {
val key = Set("file_id")
def extract(row: Row) = {
new Photo(
row.bigInt("file_id").get,
row.string("file_name").get
)
}
}
This seems to match up with the join examples given in the
documentation, but I keep getting a rune time error of
"java.util.NoSuchElementException: None.get". If I switch both of my
Photo class argument types to Option[T] the error goes away, but
entry.files contains a list that contains a single empty Photo
object. This doesn't seem right to me. What am I missing?