我正在转换为 Coldfusion 的 ORM,想知道如何使用 ORM 复制 cfoutput 的分组?
我收到以下错误:Can't cast Object type [java.util.ArrayList] to a value of type [query]
询问:
qryGames = ormExecuteQuery("from Game where Season.seasonID=:sid and League.leagueID=:lid and Season.User.userID=:uid order by League.leagueName, GameType.gameTypeID, gameDate DESC", {sid=url.sid, lid=leagueID, uid=session.userID});
代码:
<cfif arraylen(qryGames) GT 0>
<cfoutput query="qryGames" group="leagueName">
<cfoutput group="gameTypeName">
...
</cfoutput>
</cfoutput>
</cfif>
我没有看到 cfloop 的分组属性。我总是可以手动复制它,但想知道是否有内置的方法可以做到这一点。
更新#1
使用entityToQuery
:
qryGames = entityToQuery(ormExecuteQuery("from Game where Season.seasonID=:sid and League.leagueID=:lid and Season.User.userID=:uid order by League.leagueName, GameType.gameTypeID, gameDate DESC", {sid=url.sid, lid=leagueID, uid=session.userID}), "League");
我收到以下错误:
Message column [gameTypeName] not found in query, columns are [leagueID,leagueName,leagueAbbr,teamName,gameInMinutes,deleteYN,showReportYN]
仅限于一个实体名称?