Best way to model map values in Grails?

Posted by Mulone on Stack Overflow See other posts from Stack Overflow or by Mulone
Published on 2010-05-17T14:38:39Z Indexed on 2010/05/17 14:40 UTC
Read the original article Hit count: 284

Filed under:
|
|

Hi guys, I have to implement map values in my Grails app. I have a class that can contain 0..N OsmTags, and the key is unique. In Java I would model this with a Map in each object, but I don't know how to map classes in Grails.

So I defined this class:

class OsmTag {
    /** OSM tag name, e.g. natural */ 
    String key
    /** OSM tag value, e.g. park */
    String value

    static constraints = {
        key blank:false,    size:2..80,matches:/[\S]+/, unique:false
        value blank:false,  size:1..250,matches:/[\S]+/, unique:false
    }
}

That works ok, but it's actually quite ugly because the tag key is not unique. Is there a better way to model this issue?

Cheers

© Stack Overflow or respective owner

Related posts about grails

Related posts about map