I have a domain Class DailyBooking
and a generated Controller. In the update function I'm calling userService.computeFlexTime(dailyBookingInstance)
. There I want to get the current persisted entry from DailyBooking (from the database):
DailyBooking currentEntry = DailyBooking.findByUserAndDate(dailyBookingInstance.user, dailyBookingInstance.date)
From my understanding I should get the current persisted entry from the database because I'm calling the service before the save statement in the update function. But when I actually debug, currentEntry has values from the updated object. Additionally the new values are already written in the database without calling save.
update method:
if(dailyBookingInstance.end != null){
userService.computeFlexTime(dailyBookingInstance)
}
dailyBookingInstance.save flush:true
Another question is why does this method has an effect on the dailyBookingInstance in my Controller since its not returned? I think in Java I would have to work with ref
or smth. like that.
Try with the getPersistentValue function