如何通过关系和来查询?
我有一个grails域类Character
class Character {
String name
int level
boolean alive
Player player
static constraints = {
name(blank:false, unique:true)
level(min:1)
player(nullable:false)
}
}
我想查询具有指定玩家的角色,其中alive的值为“true”。我尝试使用以下内容,但
Character.findByPlayerAndAliveEqual(p, true)
它会生成异常
No signature of method: static java.lang.Character.findByPlayerAndAliveEqual() is applicable for argument types: (com.thestreetsgame.security.Player, java.lang.Boolean) values: [com.thestreetsgame.security.Player : 1, true]
我也尝试过findByPlayerAndAlive,结果相同。我怎样才能让这个 gorm 查询工作?
I have a grails domain class Character
class Character {
String name
int level
boolean alive
Player player
static constraints = {
name(blank:false, unique:true)
level(min:1)
player(nullable:false)
}
}
I want to query for a character with a specified player, where the value of alive is "true". I tried using the following, but it
Character.findByPlayerAndAliveEqual(p, true)
But it generates an exception
No signature of method: static java.lang.Character.findByPlayerAndAliveEqual() is applicable for argument types: (com.thestreetsgame.security.Player, java.lang.Boolean) values: [com.thestreetsgame.security.Player : 1, true]
I've also tried findByPlayerAndAlive
, with the same result. How can I make this gorm query work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哎呀,异常的重要部分突然出现在我面前。
我试图在核心 java 类而不是我的域类上进行查找。需要始终使用完全限定名称,或者更改类的名称。
目前我已经完全验证了该参考,并且它正在工作。
Oops, the important part of the exception just jumped out at me.
I was trying to do a lookup on the core java class instead of my domain class. Need to always use the fully qualified name, or change the name of the class.
For the time being I've fully qualified the reference, and it is working.