2011-12-01 51 views
3

在映射器的具有字符串作为主键,这是为什么在经由Mapper's allFields方法为什么MappedStringIndex不包含在fieldList中在映射器

我的映射获得的所有字段的列表中未显示的MappedStringIndex像这样...

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列表显示向上

回答

2

的PrimaryKey字段(任何数据类型)是不包括在由映射器的allFileds方法返回的列表。

您可以单独,如果你想在前面加上现场

var myMapperPrimaryKey=DummyMapper.primaryKeyField 
    var fieldList=DummyMapper.allFields.toBuffer[BaseField] 
    fieldList.prepend(myMapperPrimaryKey) 

// Now fieldList is having the primaryKey along with other fields. 
相关问题