[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2952) Support for referencing non-root entities in Criteria SQL expressions

Julian Wood (JIRA) noreply at atlassian.com
Thu Jan 29 21:24:38 EST 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32224#action_32224 ] 

Julian Wood commented on HHH-2952:
----------------------------------

Would love to see this.

Here's my use case:

        Criteria criteria = session.createCriteria(Message.class);
        criteria.createAlias("folder", "f");
        criteria.createAlias("f.owner", "owner");
        criteria.add(Restrictions.eq("owner.username", recipient.getUsername()));
        criteria.add(Restrictions.sqlRestriction("f1_.FolderType = 'Inbox'"));

I'm looking for messages whose folder has a discriminator (FolderType) of 'Inbox'.

Can I rely on the fact that hibernate called my folder alias f1_ in my sql restriction? This would be more reassuring, as described above:

criteria.add(Restrictions.sqlRestriction("{f}.FolderType = 'Inbox'"));

(Or how can I make a discriminator into an accessible property?)

J

> 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
>
> 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