玩MongoDB Morphia插件抛出错误
我在 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。引发的错误是:值过滤器不是对象模型的成员。用户
我无法解决此问题。这是相关的应用程序conf:
#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
我使用play 1.2.2RC2。和吗啡插件 morphia-1.2.1beta6
I have really simply domain model in 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
the test code:
if (User.filter("cid", session.getId).get() == null) {
....
}
the first line of test code throws error:
Compilation error
The file /app/controllers.scala could not be compiled. Error raised is : value filter is not a member of object models.User
I am unable to fix this problem. This is related application conf:
#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
I using play 1.2.2RC2. and morphia plugin morphia-1.2.1beta6
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为 PlayMorphia 模块可以与 Scala 一起使用
I don't think PlayMorphia module works with Scala