Sanket Deshpande
Sanket Deshpande

Reputation: 313

Grails domain List field not being persisted

I have a domain class

class Something {
    String name
    String email
    List<String> friends = []
}

In the domain class itself I have a method for Something objects which populates the friends list. But for some reason I am not able to persist this list. and it gets made null on browsing away from the gsp relevant to the domain modifying action.

Any suggestions as to why this is happening?

Upvotes: 0

Views: 1399

Answers (1)

tim_yates
tim_yates

Reputation: 171164

I think you instead need to write your domain as:

class Something {
    String name
    String email
    List friends
    static hasMany = [ friends: String ]
}

Upvotes: 2

Related Questions