2
votes

There are other questions like this, but none of them helped me.

I've got an external database with the table 'team' and the columns 'username' and 'password'. In my Grails-Project I want to map my User-class correctly:

class User {

     String username
     String passwordHash 

      static mapping={
         table 'team'
         version false
         passwordHash column: 'password' 
         id column: 'username'
      }
  }

I keep getting MappingException: Repeated column in mapping for entity: User column: username (should be mapped with insert="false" update="false").

Any ideas?

1

1 Answers

3
votes

If you are explicitly using a column to be the identifier than the default identifier id provided by grails, then you need to specify the name of the field in Custom ORM mapping for id as shown below:

class User {

 String username
 String passwordHash 

  static mapping={
     table 'team'
     version false
     passwordHash column: 'password' 
     id column: 'username', name: 'username'
  }
}