Having trouble creating an object "from scratch" (in code instead of from forms) in Grails. The following is the code snippet from a method in a controller (Assessment).
def newVol = new Vol(
volType:type,
app: assessmentInstance.app,
assessment:assessmentInstance,
dateFound: assessmentInstance.assDate,
urlParam: url,
volName: "TEST",
volNote: "TEST"
)
newVol.save(validate:false,flush:true, failOnError:true)
result is this error:
Class
org.postgresql.util.PSQLException
Message
ERROR: cannot execute nextval() in a read-only transaction
the id is mapped to a generator in the Vol class:
static mapping = {
id column:'vol_id'
id generator: 'sequence',params:[sequence:'scan_sequence']
}
I really don't understand how a save could be thought of as a read-only transaction. I tried messing around with the @transactional settings on my domain class, first putting readOnly to false and then removing the @transactional but it did not change things. It looks like I should look for alternatives to using a database sequence. What do you think?
UPDATE removed the readonly=true from the controller where the above code lives and that worked. But... what are the side effects of removing that?