I have the following problem:
My object route contains a list of routepoints. When I alter this list, the changed list is saved. But when the next method accesses the list, it seems like the change reverted. I ruled some kind of transaction rollback out, b/c on the end of the altering method, i acces the list by loading it from the database and it still has the right (altered) size. Here's the code:
First the altering method:
def removeStationFromRoute(station){
def driver = Driver.get(Integer.valueOf(requestAccessService.getParams().userId))
def route = driver.routes.find{
it.routeDate == new Date().clearTime()
}
def rp = Routepoint.findByStation(station)
route.routepoints.remove(rp)
def newRoute = driver.routes.find{ it.routeDate == new Date().clearTime()}
println 'new route size: ' + newRoute.routepoints.size()
def newRoute2 = Route.get(route.id)
println 'new route from db size: ' + newRoute2.routepoints.size()
}
Both prints return a size of 5, which is correct. Right after this method is carried out, this method is executed:
def getDriverRoute(){
def driver = User.get(Long.valueOf(params.userId))
def route = driver.routes.find{ it.routeDate == new Date().clearTime()}
println 'serialized route size: ' + route.routepoints.size()
def routeString = jobService.serializeRoute(route)
log.info('Route with ' + route.routepoints.size() + " stations serialized for User " + driver.encodeAsHTML())
render routeString
}
Which prints a size of 6, as if no change happened to the list. I already tried saving the driver, the route and the routepoint after the change is made in the "removeStationFromRoute"-List, as well as checking the three objects for errors. Didn't help.
Thanks for any ideas what to do!