[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-879) Enable joining the same association twice with Criteria
Bernhard Hablesreiter (JIRA)
noreply at atlassian.com
Tue Mar 30 10:33:37 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-879?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36025#action_36025 ]
Bernhard Hablesreiter commented on HHH-879:
-------------------------------------------
I came across this issue a while ago and ended up writing a sort of "wrapper" around the criteria, especially the associations.
The problem usually appears when you have some dynamic query builder which adds the association-paths to the criteria more than once.
A simple approach to avoid this problem (and quite easy to implement) could be the following:
- Create a data-structure (this must be some kind of tree) which holds an association path, a list of child-nodes and a list of criterions/order/etc.
- Add your criterions/orders/etc. to the wrapper object
- Create the criteria using your wrapper object:
This method must be recursive. Using this approach you should only create the sub-criterias once (calling criteria.createCriteria(associationPath)) and then add the list of criterions/orders/projections or whatever, coming from the wrapper.
The tree-structure could look like this:
root
+association1
-criterion1
-criterion2
+association2
-criterion1
-criterion2
+subassociation1
-criterion1
-criterion2
This structure is required for fetching associations over multiple hierarchies. Each node can have child-nodes and lists of criterions/orders/etc.
I think this is quite easy to implement and should work in most cases.
> Enable joining the same association twice with Criteria
> -------------------------------------------------------
>
> Key: HHH-879
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-879
> Project: Hibernate Core
> Issue Type: Improvement
> Components: core
> Reporter: Vladimir Bayanov
>
> Make double joining the same association with Criteria.createCriteria possible. See: http://forum.hibernate.org/viewtopic.php?t=931249
--
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