Saturday, March 12, 2016

Grails 3 : ORM Mapping Invalid: Specified config option


I have the following error at startup of my GRAILS 3.1.1 application :

ERROR org.grails.orm.hibernate.cfg.HibernateMappingBuilder - ORM Mapping Invalid: Specified config option [name] does not exist for class [toolprod.Machine]!

The consequence was that it can't create the table Machine.

Here is my domain class which had the error :

 class Machine {  
   /**  
    * Name of the web server.  
    */  
   String name  
   /**  
    * IP address.  
    */  
   String ipAddress  
   /**  
    * Application list in this machine.  
    */  
   Set<App> apps = []  
   /**  
    * Servers list.  
    */  
   Set<Server> servers = []  
   static hasMany = [apps : App, servers : Server]  
   static mapping = {  
     sort "name"  
   }  
   static constraints = {  
     name()  
     ipAddress(nullable: true)  
   }  


   
To solve this issue, I set a default value for name    :

   static constraints = {  
     name(nullable: false)  
     ipAddress(nullable: true)  
   }