title: Grails mongodb-morphia plugin - dynamically set domain collection mapping
body: <p>I would like to map a domain class to a DBCollection based on a param set in a grails app.  I'm relatively new to Spring, Grails, and MongoDB.</p>
  
  <p>I have a mongodb database with several large collections, and I would like to let the user select which collection to map the domain class to.  Ideally, the domain class could be remapped over and over again, switching between different collections.</p>
  
  <p>I'm designing the front end of the web-app, with the back-end being handled elsewhere...I'll know the Mongodb db name, but the number and name of the collections within that db will be unknown.</p>
  
  <p>Unfortunately, Morphia's Entity notation only accepts a String constant, so I can't pass something dynamic to that.  I'm thinking that I need to manually unmap the domain class, change the collection settings, and remap the class (delete beans maybe?).  I'd appreciate any suggestions on how to accomplish this, preferably using the mongodb-morphia plugin.  </p>
  
  <h2>I created a mongodb domain class similar to this:</h2>
  
  <pre><code>package x
  
  import java.util.Date;
  import com.google.code.morphia.annotations.Embedded;
  import com.google.code.morphia.annotations.Entity;
  
  @Entity("someCollection")
  class MongoLog {
  
          def Mongo
          def someService
  
          Date a
          String b
          String c
          Double d
  
          static constraints = {
                  a(nullable:true)
                  b(nullable:true)
                  c(nullable:true)
                  d(nullable:true)
          }
  }
  </code></pre>
  
  <p>P.S.  I tried using static mapping, but the mongodb-morphia plugin didn't seem to register the collection I specified.</p>
  
  <p>Thanks </p>