[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6353) DetachedCriteria: get sql alias used for sql projection or sql restriction
Lynne Brown (JIRA)
noreply at atlassian.com
Mon Aug 1 22:27:03 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43155#comment-43155 ]
Lynne Brown commented on HHH-6353:
----------------------------------
Regarding possible syntax: to be consistent with the use of {root} to refer to the root table, references to aliases of joined tables could be the alias name enclosed in braces:
detachedCriteria.add(Restrictions.sqlRestriction("{g}.name='John'"));
detachedCriteria.setProjection(Restrictions.sqlProjection("{g}.name"));
> DetachedCriteria: get sql alias used for sql projection or sql restriction
> --------------------------------------------------------------------------
>
> Key: HHH-6353
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6353
> Project: Hibernate Core
> Issue Type: Improvement
> Components: query-criteria
> Environment: Java 6, Jboss 5.1.0, Hibernate 3
> Reporter: Dave
>
> A method to get sql alias is needed from DetachedCriteria in order to use
> non-root entity alias in sql restriction or sql projection.
> DetachedCriteria:
> String getSqlAlias(String alias) // alias has been created
> detachedCriteria.createAlias("group","g");
> String sqlAlias = detachedCriteria.getSqlAlias("g");
> detachedCriteria.add(Restrictions.sqlRestriction(sqlAlias + ".name='John'"));
> detachedCriteria.setProjection(Restrictions.sqlProjection(sqlAlias + ".name"));
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list