user2782001
user2782001

Reputation: 3488

Grails Hibernate persistent set: how to not save automatically

I have a domain class Teacher that has many Students.

When I use

Teacher.students.each{it->
      it.lastupdated=date;
}

The property for the student is persisted to the database automatically (and seemingly immediately).

Is there a way to prevent this behavior and have the values be transient until I explicitly save them?

Upvotes: 0

Views: 680

Answers (1)

Joch
Joch

Reputation: 230

Simply with it.discard() to avoid the auto-save. Check the Grails documentation here.

Another solution, which may not work for your Grails version, is to add this on your configuration file:

hibernate {
    flush.mode='manual'
}

Upvotes: 1

Related Questions