gorm-hibernate5
gorm-hibernate5 copied to clipboard
removing from a collection mapped as a bag triggers a fetch of the whole collection
Task List
- [x] Steps to reproduce provided
- [ ] Stacktrace (if present) provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)
Steps to Reproduce
- run the Example Application
- navigate to http://localhost:8080/test/index to trigger the issue for many-to-many
- navigate to http://localhost:8080/test/index2 to trigger the issue for one-to-many
Expected Behaviour
as per documentation, it is not expected that the whole collection is being fetched see section 5.4.3 here: http://gorm.grails.org/6.1.x/hibernate/manual/#sets "...adding to or removing from collections mapped as a Bag don’t trigger a load of all existing instances from the database..."
Actual Behaviour
The whole locations collection is fetched when calling post.removeFromLocations(location)
, which is very costly if there are thousand of items in the database.
Environment Information
- Operating System: MacOS
- GORM Version: 6.1.11.RELEASE
- Grails Version (if using Grails): 3.3.9
- JDK Version: jdk1.8.0_121
Example Application
- https://github.com/bp-FLN/gorm-removeFromBag-issue