MapperDao supports persisting binary data into blob columns. The mapping is currently done via Array[Byte]
.
For example lets map the following table:
create table Image(
id serial primary key,
name varchar(20) not null,
data blob not null
)
Our entity needs an Array[Byte]
to represent the data and then the mapping is straight forward:
case class Image(name: String, data: Array[Byte])
object ImageEntity extends Entity[Int,SurrogateIntId, Image] {
val id = key("id") autogenerated (_.id)
val name = column("name") to (_.name)
val data = column("data") to (_.data)
def constructor(implicit m) = new Image(name, data) with Stored {
val id: Int = ImageEntity.id
}
}