我在scala中有非常简单的域模型:
package models
import org.joda.time.DateTime
import com.google.code.morphia.annotations.Entity;
import play.data.validation.Required;
import play.modules.morphia.Model;
@Entity
class User(@Required val cid: String, val isAdmin: Boolean = false, @Required val dateJoined: DateTime = new DateTime() ) extends Model
测试代码:
if (User.filter("cid", session.getId).get() == null) {
....
}
第一行测试代码抛出错误:
编译错误 文件 /app/controllers.scala 无法编译。引发的错误是:值过滤器不是对象模型的成员。用户
我无法解决这个问题。这是相关的应用程序配置:
#module.morphia=${play.path}/modules/morphia-1.2.1beta6
morphia.db.host=localhost
# what's your mongodb server port
morphia.db.port=27017
# what's your database name
morphia.db.name=gem
# Authentication to your mongodb server
#morphia.db.username=user
#morphia.db.password=pass
# configure your ID field type
# could be either ObjectId or Long, default to ObjectId
morphia.id.type=Long
# Set default write concern, see http://api.mongodb.org/java/current/com/mongodb/class-use/WriteConcern.html
#morphia.defaultWriteConcern=safe
我使用播放 1.2.2RC2。和 morphia 插件 morphia-1.2.1beta6