2011-12-01 49 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. 
相關問題