Search code examples
springmongodbspring-roo

How to Entity with dynamic fields into Spring Roo Entity


I have a Logging Entity that needs to map an Entity that is a dynamic set of Properties where the JSON data looks like this:

{ 
"timestamp" : ISODate("2012-01-17T22:30:19.839Z"), 
"level" : "INFO", 
"thread" : "main", 

"properties" : { 
    "cookieId" : "EDE44DC03EB65D91657885A34C80595E" 
    "field-1" : "foo" 
    "field-n" : "bar" 
}, 

"applicationName" : "D2", 
"eventType" : "Development" 
}

How can I create a Properties object that is dynamic for pulling fields?

Any help would be greatly appreciated.


Solution

  • U should create field like java.util.Map .
    example:
    field other --fieldName properties --type java.util.Map

    I try that with web mvc, but it's not working property, because a custom editor not exist for this type.....
    So if U wanna use with spring mvc U have to write your custom editor for that.

    PS: after you created this field recommended change that generic type to <String,Object>...