From: Manuel D. S. (JIRA) <no...@at...> - 2006-06-29 13:14:20
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1700?page=comments#action_23490 ] Manuel Dominguez Sarmiento commented on HHH-1700: ------------------------------------------------- I've executed a query similar to the one you describe (same query, different table) directly in Oracle and it works fine. Judging from the error code, it seems like the ? parameter replacement does not match the SQL type in the table. Make sure you pass the correct array of Hibernate Type instances to the CustomProjections factory, that sounds like the culprit. You can get instances of Type from static fields in class Hibernate (Hibernate.LONG, Hibernate.STRING, etc.) > HAVING clause not supported in Criteria API > ------------------------------------------- > > Key: HHH-1700 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1700 > Project: Hibernate3 > Type: New Feature > Components: query-criteria > Versions: 3.1.3 > Environment: Hibernate 3.1.3, Oracle 10g (not DB specific) > Reporter: Manuel Dominguez Sarmiento > Priority: Minor > Attachments: CustomProjections.java > > Original Estimate: 2 hours > Remaining: 2 hours > > Currently the Criteria API does not support the HAVING clause. I have create a factory class which creates Projection instances using sqlGroupProjection. Probably not the best approach, but an idea which could be further developed. These factory methods could be included in the Projections factory class. > Usage example w/one property: > criteria.setProjection(CustomProjections.groupByHaving("id", Hibernate.LONG, "count(distinct id) >= 3")); > Also allows aliases: > criteria.setProjection(CustomProjections.groupByHaving("id", "idAlias", Hibernate.LONG, "count(distinct idAlias) >= 3")); > Usage example w/many properties: > String[] columns = new String[2]; > columns[0] = "id"; > columns[1] = "name"; > String[] aliases = new String[2]; > aliases[0] = "idAlias"; > aliases[1] = "nameAlias"; > Type[] types = new Type[2]; > types[0] = Hibernate.LONG; > types[1] = Hibernate.STRING; > criteria.setProjection(CustomProjections.groupByHaving(columns, aliases, types, "count(distinct id) >= 3 and name='george'")); -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |