Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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
Hibernate GORM:hql查询产生异常:无法解析属性_Hibernate_Grails_Gorm - Fatal编程技术网

Hibernate GORM:hql查询产生异常:无法解析属性

Hibernate GORM:hql查询产生异常:无法解析属性,hibernate,grails,gorm,Hibernate,Grails,Gorm,晚上好, 我的数据库中有一个名为Events的表,它有两个字段:数据类型DATE的START_DATE和END_DATE。 我还创建了一个名为Event的域类,如下所示: class Event{ Date startDate Date endDate static mapping = { table 'events' startDate column: 'start_date' endDate column: 'end

晚上好,

我的数据库中有一个名为Events的表,它有两个字段:数据类型DATE的START_DATE和END_DATE。 我还创建了一个名为Event的域类,如下所示:

class Event{

    Date startDate
    Date endDate

    static mapping = {
        table 'events'
        startDate column: 'start_date'
        endDate column: 'end_date'
    }
}
然后我创建了一个EventsService,它查询数据库中两个日期之间开始和结束的事件。目前,我正在尝试使用以下代码获取在两个日期之间开始的事件:

String hql = "select e from Event e where e.startDate >= :startDateMin and e.startDate <= :startDateMax"
params.put("startDateMin",filter.getStartDateMin())
params.put("startDateMax",filter.getStartDateMax())
def results = Event.executeQuery(hql,params,config)

String hql=“从事件e中选择e,其中e.startDate>=:startDateMin和e.startDate它似乎没有拾取列名。我在GORM中看到了一些类似的奇怪问题

试试这个:

  • 阻止雄猫
  • 删除了Tomcat临时目录中的所有文件
  • 重新启动的雄猫

  • 让我知道这是否有帮助。

    不幸的是,你的建议没有起作用。不过,我只需将两个变量的名称完全更改为eventStart和eventEnd,并将它们映射到表的列,就成功了。我不知道出了什么问题,尝试在屏幕上打印类的所有属性,以查看在运行时注入同名字段时,我搜索了继承树,但什么也没搜索到。在此之前,我曾尝试将数据库中的数据类型更改为Timestamp和各种奇怪的事情,但都没有效果。因此,对于任何与grails 2.2.1有相同问题的人,请首先尝试更改变量的名称

    谢谢你抽出时间

    Caused by: org.hibernate.QueryException: could not resolve property: startDate of: ipmt.modules.Event [select e from ipmt.modules.Event e where e.startDate >= :startDateMin and e.startDate <= :startDateMax]