[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6353?page=c...
]
Lynne Brown edited comment on HHH-6353 at 8/11/11 12:35 PM:
------------------------------------------------------------
Regarding possible syntax: to be consistent with the use of {alias} 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"));
was (Author: lynnebrown):
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