[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2952) Support for referencing non-root entities in Criteria SQL expressions
Günter Graf (JIRA)
noreply at atlassian.com
Fri Jul 10 01:47:12 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33585#action_33585 ]
Günter Graf commented on HHH-2952:
----------------------------------
Thanks, I'll give it a try.
I was wondering if we could avoid changing the visibility of the getAliasedCriteria(String) method and adding the getter.
your code to get the aliased criteria is:
cri = ((org.hibernate.loader.criteria.CriteriaQueryTranslator) criteriaQuery).getAliasedCriteria(alias);
Due to lack of time, I haven't tried it out yet, but my idea is to use
cri = (Criteria) ((org.hibernate.loader.criteria.CriteriaQueryTranslator) criteriaQuery).getRootCriteria().iterateSubcriteria().next();
to recursively iterate over all criterias and then use the
cri.getAlias()
or
criteriaQuery.getSQLAlias(criteria)
method to get the alias property.
Do you think, that could be possible? Maybe you have allready made experiences with the iterateSubcriteria() method.
To get the outerQueryTranslator we could use reflection (if it is allowed in the java security manager (ReflectPermission)).
> 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, 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