Ramesh Karna
Ramesh Karna

Reputation: 816

Grails introduce an extra column in predefined table

I just started Grails programming, and I was trying to access the table which was predefined and accessed by other application, Table contains only 3 columns id, filename, msgcount. I successfully connect and access the table through grails. Until this everything is going fine, but when I run the main application (previously, which was accessing the table) I faced an error, which was about table attribute mismatch, so I went through the table design and found that there was an extra column named 'version'. I am bit surprised by that extra column but after some diagnosis I realized that that column is added by grails application.

Is this addition of extra column is normal. Is there any solution so grails application doesn't change the tables's attribute (i.e. addition of extra column) which may bound us for using the same table for multiple application.

Upvotes: 1

Views: 184

Answers (1)

techfoobar
techfoobar

Reputation: 66693

Yes, this is the default behavior of grails GORM. See this explanation: http://grails.org/doc/latest/guide/GORM.html#optimisticLockingAndVersioning

You can solve it in 2 ways:

a) Create a version field in your db table

OR

b) You can disable the version field from your domain class as follows:

class YourDomainClass {

   static mapping = {
       version false
   }

   ...

}

Upvotes: 2

Related Questions