Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails.findBy不';我不能和redis一起工作_Grails_Redis_Gorm_Grails Plugin - Fatal编程技术网

Grails.findBy不';我不能和redis一起工作

Grails.findBy不';我不能和redis一起工作,grails,redis,gorm,grails-plugin,Grails,Redis,Gorm,Grails Plugin,我有一个非常简单的测试用例,用来理解redis。我确实安装了插件redis gorm 域对象: class BenchGroup { String groupName /*static mapWith = "redis" static mapping = { groupName(index:true) }*/ static constraints = { } } 引导代码: def everyoneGroup = new BenchGroup(groupName

我有一个非常简单的测试用例,用来理解redis。我确实安装了插件redis gorm

域对象:

class BenchGroup {
  String groupName
  /*static mapWith = "redis"
  static mapping = {
    groupName(index:true)
  }*/
  static constraints = {
  }
}
引导代码:

def everyoneGroup = new BenchGroup(groupName:'everyoneGroup')
everyoneGroup.save()
if(everyoneGroup.hasErrors()){
  println everyoneGroup.errors
}
println everyoneGroup
def dammit = BenchGroup.findByGroupName('everyoneGroup')
println dammit
当我离开redis地图行时,它使用HSQL并输出以下内容:

stupidbenchmarks.BenchGroup : 2
stupidbenchmarks.BenchGroup : 2
当我切换到redis时,它会执行以下操作:

stupidbenchmarks.BenchGroup : 2
null

i、 e..findBy不起作用。

Hibernate在执行查询之前刷新(在本例中为
findByGroupName
),但NoSQL GORM数据存储实现不起作用(目前),因此我假设您只需要刷新即可将保存的实例推送到数据存储,以便查询将其拾取:

everyoneGroup.save(flush: true)

通过卸载hibernate插件并重新安装“redis gorm”(也安装了“redis”插件,所以我去掉了它),然后从域类中删除mapWith line,修复了这个问题。刷新似乎没有必要-代码现在在没有刷新的情况下按预期工作。