title: How can I prevent unwanted doctrine persists in symfony 4?
body: <p>At this point, I'm not sure if the problem is with doctrine or with symfony.</p>
  
  <p>I have an entity called Field.  It has a property dataTable with the usual getter and setter methods.  In one of my supporting classes, I use the setter method to change dataTable to a temporary value.  I never call persist in this class or the controller that calls it.  However, I'm finding that the database is getting updated with this temporary value.</p>
  
  <p>If need be, I can add a virtual property and use that instead, but I think the code would be cleaner if I can avoid that.  How can I ensure that doctrine only persists things I explicitly tell it to?</p>
  
  <p>Entity Mapping:</p>
  
  <pre><code>type: entity
  
  gedmo:
    soft_deleteable:
      field_name: deletedAt
      time_aware: false
  
  id:
    id:
      type: integer
      generator:
        strategy: auto
  
  fields:
    name:
      type: string
    sortorder:
      type: integer
    dataTable:
      type: string
    type:
      type: string
    columnAdded:
      type: boolean
    deletedAt:
      type: date
      nullable: true
  
  manyToOne:
    section:
      targetEntity: Domain\Model\Section
      inversedBy: fields
  
  oneToMany:
    fieldOptions:
      targetEntity: FieldOption
      mappedBy: field
  
  oneToOne:
    zmrList:
      targetEntity: Domain\Model\ZmrList
  </code></pre>
  
  <p>Relevant controller code: (Persist is never called for anything in the controller)</p>
  
  <pre><code> $columns = $this-&gt;queryBuilder-&gt;getListColumns($list);
   $filters = $this-&gt;queryBuilder-&gt;composeListFilters($list);
   $query = $this-&gt;queryBuilder-&gt;build($columns, $filters, $list-&gt;getForm()-&gt;getId(), $instanceId);
  </code></pre>
  
  <p>Relevant code in the QueryBuilder:</p>
  
  <pre><code> foreach ($details['columns'] as $k=&gt;$layerColumn) {
                          $this-&gt;columns[$layerColumn]-&gt;getField()-&gt;setDataTable('table_'.$alias);
  }
  </code></pre>
  
  <p>Setter Function:</p>
  
  <pre><code> /**
       * @param string $dataTable
       */
      public function setDataTable(string $dataTable): void
      {
          $this-&gt;dataTable = $dataTable;
      }
  </code></pre>