在Mapper中将String作为主键,为什么在 Mapper's allFields
方法 <获取的所有字段的列表中 MappedStringIndex未显示 / p>
My Mapper就是这样......
class DummyMapper extends KeyedMapper[String,DummyMapper] {
def getSingleton = DummyMapper
def primaryKeyField = dummyCode
object dummyCode extends MappedStringIndex(this,5)
{
override def writePermission_? = true
override def dbAutogenerated_? = false
override def dbNotNull_? = true
override def dbColumnName="dummy_code"
}
.....
我甚至尝试过包括在fieldOrder
中。结果仍然相同,在DummyMapper.allFields
列表
答案 0 :(得分:2)
主要字段(任何数据类型)在Mapper的allFileds
方法返回的列表中不包含。
如果需要,可以单独添加字段
类似
var myMapperPrimaryKey=DummyMapper.primaryKeyField
var fieldList=DummyMapper.allFields.toBuffer[BaseField]
fieldList.prepend(myMapperPrimaryKey)
// Now fieldList is having the primaryKey along with other fields.