Grails / Groovy - Domain Object - Map of its Properties

前端 未结 3 2067
无人及你
无人及你 2021-01-18 06:18

How can I get a map of the key/values of only the user-defined properties on one of my domain objects?

Problem is if I do this myself, I get my properties plus class

3条回答
  •  梦谈多话
    2021-01-18 07:03

    I think the best way is to use .properties on a domain object to get map of the fields in grails , tested in grails 2.1

    class Person{
    String firstName
    String lastName
    
    } 
    def person=new Person()
    person.firstName="spider"
    person.lastName="man"
    def personMap=person.properties 
    

提交回复
热议问题