title: Groovy Dynamic Object - How to properly reset properties?
body: <p>Based on <a href="https://stackoverflow.com/questions/6568397/groovy-dynamic-property-per-object">this question</a> I created a Groovy class that will have dynamic properties.</p>
  
  <pre><code>class MyDynamic {
    def propertyMissing( String name, value ) {
      this.metaClass."$name" = value
      value
    }
  }
  </code></pre>
  
  <p>So far all good, now I can set some non-existent property with success</p>
  
  <pre><code>MyDynamic dyna = new MyDynamic()
  dyna.someProp = new Date()
  </code></pre>
  
  <p>My problem begins when I have another instance with the same name of property, but with another type</p>
  
  <pre><code>MyDynamic dyna2 = new MyDynamic()
  dyna2.someProp = "0" //GroovyCastException: Cannot cast object '0' with class 'java.lang.String' to class 'java.util.Date'
  </code></pre>
  
  <p>Actually I need this because I'm creating objects with the result of a query without knowing the table and the column. I get the name of the column with the <code>ResultSetMetaData</code> and add the property to the instance of the dynamic object. Later I will use this object to export all the properties and values. In different tables I have the same column name, but with different types.</p>
  
  <p>So my question is: how can I reset this metaClass when I'm done with the instance to not conflict with other instance? </p>