Closed bruno-lopes closed 3 months ago
I am able to reproduce this with a simple create-app and adding the plugin as you suggested. Still trying to hunt down the issue but glancing through GORM 6.1 and Grails 3.3 repos I haven't seen any changes that would explain the sudden failure.
@alexkramer, thanks for your response. I created a pull request. Could you please take a look? Thanks in advance!!!
From what I can tell the contract hasn't changed. Were you able to trace down why you need to explicitly pass the classes in 3.3?
@bruno-lopes Thanks for opening that PR. I pushed up a branch I had been working on to upgrade the project to Grails 3.3.0.RC1 to test out the fix you proposed. Please take a look as it appears that your proposal does not fix the issue. Did you try your fix in Grails 3.3.x? Because I am finding that the plugin is still broken.
I opened a PR so you can easily see the diff between the Grails 3.3.x branch of the plugin and Master: https://github.com/alexkramer/grails-hibernate-filter/pull/5
I read through a lot of the Grails Hibernate5 plugin source and am struggling to see what changed there between the implementation for GORM 6.0 and 6.1 that would have lead to this issue. I am suspecting the issue may be farther upstream.
@alexkramer, sorry for my delay in responding your question. I'm using a multi-project application, using Grails 3.3.0.M2. I didn't try that with Grails 3.3.0.RC1. Also, I didn't updated all the dependencies, like you did. I'll update to Grails 3.3.0.RC1 in order to see what happens. Thanks!
The same problem using version 0.5.3 and grails 3.3.2.
The issue is related to a change in the domain class API. Besides deprecation they removed access to some of the classes during setup. If you see the branch I have open you can see the progress I have made thus far towards removing the deprecated references. Please see the following to provide some clarity around the issue:
http://docs.grails.org/latest/guide/upgrading.html#_grails_domain_class_api_deprecated
I have been working on this (admittedly sporadically) and you can see the progress I have made on the branch and the open PR.
Okay, thanks for the clarifications. I need to urgently implement a filter in my application, would you have any suggestions?
What needs to be done for this to be merged?
I spent another morning looking into this but I still cannot figure out why the running application is unable to get access to the persistent entities. I don't have a clear understanding for what is wrong because the documentation I can find is sparse and I struggle to find another open source project that has a similar requirement -- the hibernate search plugin may have some answers but thus far they have eluded me.
To answer your question then, I do not know what is left to make this actually work and therefore merge it in. It could either be a small change that I missed or it could be the the entire plugin needs to be reworked.
Another thought that I had is why this plugin still needs to exist. Multi tenancy support in GORM for Hibernate uses hibernate filters which means the main plugin already works with them. It would seem to be not to much of an extension to support this use case.
In any event, if any of you wants to try and pull down the 3.3.x branch of this plugin and give it a go, please do! I could use some help.
Hi. I tried to use version 0.5.4 of this plugin with my grails 3.3.9 application. However, when using multiple datasources I get an exception during startup:
org.grails.datastore.mapping.model.MappingContext.getPersistentEntity(java.lang.String)] cannot be accessed before GORM has initialized
This one is triggered because at HibernateFilterBuilder, line 79 there is a call to domainClass.isRoot()
and the method implementation has changed in grails 3.3.x.
If I use the old implementation of the method, it works fine. So instead of calling domainClass.isRoot() I added a separate method:
boolean isRoot(GrailsDomainClass domainClass) { final Class<?> superClass = domainClass.getClass().getSuperclass() DomainClassArtefactHandler.isDomainClass(superClass) ? false : true }
I know it still uses the deprecated classes but it is functional.
@gabivis I accepted your PR and released version 0.5.5. Please try out this version and let me know if this works for you.
Thanks a lot Alex, it works.
Hi. I'm trying to use Grails Hibernate Filter v0.5.2 in Grails 3.3.0.M2. When I add the dependency and try to run Grails application (grails r-a) it doesn't start because of the following error:
I created this project in Github to demonstrate the error (https://github.com/vaidegrails/hibernateFilterErrorInGrails3.3.0.M2).
Without the dependency, the application starts normally. I tried version 0.5.1 but the error is the same. Thanks in advance!