Donald
I have some issues with Mapper and a String as primary key.
With the LongKeyedMapper as sample, I added them for the String :
trait BaseStringKeyedMapper extends BaseKeyedMapper {
override type TheKeyType = String
}
trait StringKeyedMapper[OwnerType <: StringKeyedMapper[OwnerType]] extends KeyedMapper[String, OwnerType] with BaseStringKeyedMapper {
self: OwnerType =>
}
trait StringKeyedMetaMapper[A <: StringKeyedMapper[A]] extends KeyedMetaMapper[String, A] { self: A => }
and in my Mapped class/object et all I've:
class ApplicationSetting extends StringKeyedMapper[ApplicationSetting] {
def getSingleton = ApplicationSetting
def primaryKeyField = name
object name extends MappedStringIndex(this, 80) {
override def writePermission_? = true
override def dbIndexed_? = true
}
object setting extends MappedString(this, 200)
}
object ApplicationSetting extends ApplicationSetting with StringKeyedMetaMapper[ApplicationSetting]
Usage:
val newObj = ApplicationSetting.create.name('mypropname')
newObj.setting("hello world")
newObj.save
With the writePermission on false, i get an exception (rightly so)
With the writePermission set to true, it seems to work only the record created in the database (mysql) has the 'setting'' field filled with data, the name field is empty. (quite strange this happens for a primary key field...)
I found a primaryKeyAutogenerated : Box[Boolean] in MetaMapper, but that one is private...
Maybe it's the wrong approach for a non-autogenerated record, I would like to do something like ApplicationSetting.create('mypropname') to create on with a primary key. (but don't know what will break when I do that. )
Next to that, I'll but the overrides for the name field in an extended MappedStringIndex to make it more clear what happens.
Any pointers on solving this issue ?
Reading / Updating the setting works like charm...
import java.util.UUIDobject Thing extends Thing with KeyedMetaMapper[String, Thing] {override def dbTableName = "things"override def beforeCreate = List((thing: Thing) => {thing.thing_id(UUID.randomUUID().toString())})}class Thing extends KeyedMapper[String, Thing] {def getSingleton = Thingdef primaryKeyField = thing_id
object thing_id extends MappedStringIndex(this, 36) {
override def writePermission_? = true
override def dbAutogenerated_? = falseoverride def dbNotNull_? = true}object name extends MappedString(this, 64)}
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.