So, after a bit of research and testing the short answer is: It's really difficult to do with entityLoad().
However, with HQL, it's super easy:
<cfscript>
hql = " SELECT DISTINCT artName
FROM art
ORDER BY RANDOM() ";
results = ormExecuteQuery(hql);
for( art in results ) {
writeOutput(art & "<br/>");
}
</cfscript>
Who knew?
Basically, Hibernate will pass any functions it doesn't recognize to the underlying SQL engine. In this case, I am using Derby's 'random' function to get my random result set.
Neat, huh?
No comments:
Post a Comment