Quantcast
Channel: Spring Community Forums - NoSQL
Viewing all articles
Browse latest Browse all 128

[SOLVED] custom write converter on updating entity that contains a map

$
0
0
In short :
When doing $set update on an entity that contains a map, the bean instances inside the map's value are not converted
Code:

// this doesnt trigger the write conversion on the simpleObject.wrapper's map
Update update = new Update().set("wrapper", simpleObject.wrapper);

In order to make this work, 2 things must be done :
- On the write converter, we have to add the _class manually
- and we have to manually convert the entity by :
Code:

BasicDBObject dbObject = new BasicDBObject();
this.ops.getConverter().write(simpleObject.wrapper, dbObject);
Update update = new Update().set("wrapper", dbObject);

The source-code example with conversion failure : http://pastebin.com/1Tg9G6WJ

The source-code example with conversion success : http://pastebin.com/MYzraJzU

The context file : http://pastebin.com/SxXq5V1B

I have filed a JIRA ticket in hope to get write conversion works without these hacks.

Viewing all articles
Browse latest Browse all 128

Trending Articles