玩MongoDB Morphia插件抛出错误

发布于 2024-11-17 20:09:03 字数 1200 浏览 3 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少年亿悲伤 2024-11-24 20:09:03

我不认为 PlayMorphia 模块可以与 Scala 一起使用

I don't think PlayMorphia module works with Scala

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文