为简单起见,假设我有两个实体配置如下:
Topic.cfc
/**
* @accessors true
* @persistent true
*/
component {
/**
* @fieldtype id
* @generator uuid
* @sqltype varchar(35)
*/
property topicID;
/**
* @type array
* @fieldtype one-to-many
* @cfc Response
* @fkcolumn topicID
* @singularname response
*/
property responses;
}
Response.cfc
/**
* @accessors true
* @persistent true
*/
component {
/**
* @fieldtype id
* @generator uuid
* @sqltype varchar(35)
*/
property responseID;
/**
* @type date
* @ormtype timestamp
*/
property responseTime;
}
我需要运行一个HQL查询(或者不是,你告诉我......),它将在指定的日期范围内返回指定主题的所有响应。
我的查询目前看起来像这样:
var params = {
'start' = startDate,
'end' = endDate,
'topicID' = topicID
};
var responses = ormExecuteQuery('
from Response
where responseTime >= :start
and responseTime <= :end
and Topic.topicID = :topicID
', params );
它返回以下错误:could not resolve property: Topic of: Response [ from Response as r where r.responseTime >= :start and r.responseTime <= :end and r.Topic.topicID = :topicID ]
我尝试加入:
from Response as r
join r.Topic as t
...
但是这会导致同样的错误。不确定从哪里开始。提前谢谢!
答案 0 :(得分:2)
正如所写的那样,查询假设从响应到主题之间存在关系 - 根据您的代码,它没有。
非常确定如果将该关系添加到Response,则查询将起作用。