[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2952) Support for referencing non-root entities in Criteria SQL expressions
Ricardo Rufino (JIRA)
noreply at atlassian.com
Mon Dec 6 00:35:14 EST 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39300#action_39300 ]
Ricardo Rufino commented on HHH-2952:
-------------------------------------
I have same problem, i need use a sqlProjection for a joined table called Parcela, where the alias is "parcela".
I tried to use
projList.add(Projections.sqlProjection("sum(parcela.valor) as valor", new String[]{"valor"}, TYPES_DOUBLE), "valor");
and
projList.add(Projections.sqlProjection("sum({parcela}.valor) as valor", new String[]{"valor"}, TYPES_DOUBLE), "valor");
but not work, hibernate generate SQL fragment as:
...
inner join
Parcela parcela4_ <---- ! Adding the 4_ sufix -->
on matricula3_.id=parcela4_.Matriculaid
...
this patch should be done in hibernate
im using: Hibernate 3.6.0 and MySQL
> Support for referencing non-root entities in Criteria SQL expressions
> ---------------------------------------------------------------------
>
> Key: HHH-2952
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2952
> Project: Hibernate Core
> Issue Type: Improvement
> Components: query-criteria
> Affects Versions: 3.2.2
> Environment: Java 5, MySQL 5.0, Eclipse 3.2
> Reporter: Jacob Gyllenstierna
> Assignee: Diego Plentz
> Attachments: RestrictionsExt.java, SQLAliasedCriterion.java, SQLAliasedCriterion.java, SQLAliasedCriterion.java, SQLAliasedProjection.java
>
>
> It would be very helpful to be able to reference non-root entities in Criteria SQL restrictions and projections using placeholders similar to {alias}. A very simple but uninteresting example:
> criteria.createAlias("group", "g");
> criteria.add(Restrictions.sqlRestriction("{g}.id=:groupId"));
--
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
More information about the hibernate-issues
mailing list