title: why read-only access is writing to my db, in GORM?
body: <p>In my app, I have a code like this:</p>
  
  <pre><code>// 1
  Foo.get(123).example = "my example" // as expected, don't change value in db
  
  // 2
  Foo.get(123).bars.each { bar -&gt;
      bar.value *= -1 // it's changing "value" field in database!! WHY?
  }
  </code></pre>
  
  <ul>
  <li>note: Foo and Bar are tables in my DB</li>
  </ul>
  
  <p>Why is gorm saving in database is second case?
  I don't have any save() method in code.</p>
  
  <p>Tks</p>
  
  <hr>
  
  <p><strong>SOLVED:</strong>
  I need to use <code>read()</code> to get a readonly session.
  (Foo.discard() also works)</p>
  
  <p>Doc: <a href="http://grails.org/doc/latest/guide/5.%20Object%20Relational%20Mapping%20%28GORM%29.html#5.1.1%20Basic%20CRUD" rel="nofollow">http://grails.org/doc/latest/guide/5.%20Object%20Relational%20Mapping%20%28GORM%29.html#5.1.1%20Basic%20CRUD</a></p>
  
  <p>(In the first case, I guess I made mistest)</p>