[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-229) Filter failes on many-to-many relations

Ryan Fowler (JIRA) noreply at atlassian.com
Tue Apr 15 15:14:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30002 ] 

Ryan Fowler commented on HHH-229:
---------------------------------

I'm having this problem and I get a "PERMISSION VIOLATION" when I click on the TODO-129.  I also don't see a way to attach a file to this issue, so I'm pasting my patch into this comment. This seems to suite my purposes and the test case doesn't bomb out anymore but I'm not familiar enough with this code to guarantee correctness.

Index: src/org/hibernate/cfg/HbmBinder.java
===================================================================
--- src/org/hibernate/cfg/HbmBinder.java        (revision 14512)
+++ src/org/hibernate/cfg/HbmBinder.java        (working copy)
@@ -2940,6 +2940,15 @@
                if ( condition==null) {
                        throw new MappingException("no filter condition found for filter: " + name);
                }
+               // If this is a many-to-many association, add the filter as many-to-many
+               if(filterable instanceof Collection ) {
+                   Collection c = (Collection)filterable;
+                   if(!c.isOneToMany()) {
+                       log.debug( "Applying ManyToMany filter [" + name + "] as [" + condition + "]" );
+                       c.addManyToManyFilter(name, condition);
+                       return;
+                   }
+               }
                log.debug( "Applying filter [" + name + "] as [" + condition + "]" );
                filterable.addFilter( name, condition );
        }






> Filter failes on many-to-many relations
> ---------------------------------------
>
>                 Key: HHH-229
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-229
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.1 rc3
>         Environment: Hibernate3 RC1
>            Reporter: Magnus Sandberg
>         Attachments: filterexample.zip
>
>
> When adding a filter to a class or one-to-many relation the filtering happens as expected. When adding a filter to a many-to-many relation (and I guess other relations using a join table) the columns in the filter-condition are mapped on the join table and not the associated table - the result is failure with exception.

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