Friday, July 19, 2013

[Grails] Use Domain.withNewSession instead of refresh()

Waaaaaaay faster.
For instance, if you have a service run by a scheduled recurring Quartz job, the service seem to be attached to a thread which does not see the updated fields in the database (always returns cached values). We may refresh the whole domain calling the refresh() method on the domain class instance, or just do this:

def allCampaigns
        Campaign.withNewSession{ session ->
            allCampaigns = Campaign.findAll("from Campaign where myStatus IN ('active','paused') OR myStatus = null")

Saturday, July 6, 2013

Cleaning up /boot

dpkg --get-selections|grep 'linux-image*'|awk '{print $1}'|egrep -v "linux-image-$(uname -r)|linux-image-generic" |while read n;do apt-get -y remove $n;done