FilterPane Plugin

FilterPane Plugin returns multiple entities on a joined filter query

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Not A Bug
  • Affects Version/s: Grails-FilterPane-0.6.6
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Performing a filter on a domain class with associated domain classes. I receive multiple enitities in the result list. I think the problem lies in the outer join that is performed.

In the filter method the following change fixed the problem for me:

} // end criteria
def results = null
if (doCount) {
results = c.get(criteriaClosure)
} else {
results = c.list(criteriaClosure) // change this to c.listDistinct(criteriaClosure)
}

It seems to work, but I'm not sure if there are any side affects.

Activity

Hide
Markus Jung added a comment -

Ok, the fix that I have proposed is not a good solution.

If it comes to pagination I ran into troubles, but this happens only with the original source coude. The problems lies in the offset and maxResult behaviour of Hibernate. This topic is discussed often enough. So the solution for me is to do a workaround. By filtering the double entries at the controller, for one data 'page'.

The only thing was is to trick the filter pane plugin to count the additional rows which come up by the outer join of hibernate. I have done this by using 'dummy' where clause statements on the joined tables. So the count() returns the 'false' number of rows, but the right number of rows to use the built in pagination.

Sorry, for raising the bug.

Show
Markus Jung added a comment - Ok, the fix that I have proposed is not a good solution. If it comes to pagination I ran into troubles, but this happens only with the original source coude. The problems lies in the offset and maxResult behaviour of Hibernate. This topic is discussed often enough. So the solution for me is to do a workaround. By filtering the double entries at the controller, for one data 'page'. The only thing was is to trick the filter pane plugin to count the additional rows which come up by the outer join of hibernate. I have done this by using 'dummy' where clause statements on the joined tables. So the count() returns the 'false' number of rows, but the right number of rows to use the built in pagination. Sorry, for raising the bug.
Hide
Steve Krenek added a comment -

So is this a non-issue with the plugin? Can I close the JIRA, or should I look into a built-in workaround for this? I guess I haven't run across this yet because I haven't worked with many outer join mappings in Grails.

Show
Steve Krenek added a comment - So is this a non-issue with the plugin? Can I close the JIRA, or should I look into a built-in workaround for this? I guess I haven't run across this yet because I haven't worked with many outer join mappings in Grails.
Hide
Markus Jung added a comment -

Ok, I have found the problem. It is not related to the filter pane plugin. The problem are some eager fetch modes I have specified in my domain model. If you access asscociated domain objects in the grails view (gsp - files) you can run into a LazyInitException. So this was the reason to use eager fetch mode. The problem now is that in order to construct the object tree, hibernate has to load the associated entities. If there are multiple entities then you can duplicate rows for the root entity.

By default the filter pane plugin returns this multiple entities. The fix was to redesign the app so now eager fetching was necessary. With lazy fetching everything works fine.

I don't know if it is possible to solve an eager loading issue with filterpane plugin. I don't think so. Maybe just an hint at the plugin page is enough, to make it clear that eager fetching can lead to problems with duplicate entities.

Show
Markus Jung added a comment - Ok, I have found the problem. It is not related to the filter pane plugin. The problem are some eager fetch modes I have specified in my domain model. If you access asscociated domain objects in the grails view (gsp - files) you can run into a LazyInitException. So this was the reason to use eager fetch mode. The problem now is that in order to construct the object tree, hibernate has to load the associated entities. If there are multiple entities then you can duplicate rows for the root entity. By default the filter pane plugin returns this multiple entities. The fix was to redesign the app so now eager fetching was necessary. With lazy fetching everything works fine. I don't know if it is possible to solve an eager loading issue with filterpane plugin. I don't think so. Maybe just an hint at the plugin page is enough, to make it clear that eager fetching can lead to problems with duplicate entities.
Hide
Steve Krenek added a comment -

I'm closing this as "Not a Bug", due to Markus's comments. I've added a note to the plugin's web page referring the reader to this issue for more information.

Show
Steve Krenek added a comment - I'm closing this as "Not a Bug", due to Markus's comments. I've added a note to the plugin's web page referring the reader to this issue for more information.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: