PDA

View Full Version : Spring Data MongoDB - Property Editor Support?



matsientst
Mar 2nd, 2011, 09:57 AM
I've been taking the plunge into using MongoDB and I got a simple example working writing to and from mongo. Now I need to know how to manage property editors for the conversion? I'm not sure if it's supported but it looks like you guys have done it in the examples with TradeBatch. But you don't seem to be using a repository.

Do you have any suggestions on registering property editors? Or should I just make my object incredibly flat and marshal myself?

matsientst
Mar 2nd, 2011, 11:04 AM
After some research it looks like it should be supporting property editors out of the box. In the Person example they have an Address object which is set and then persisted and retrieved.
In my example I have an object FeedItem and a Comment object inside. A straightforward bean. However, when I save the object to my feedItemDaoRepositoryImpl I get this error:

Unable to map property dislike. Skipping.


Here is the code:

feedItemDaoRepositoryImpl.deleteAll();
for (int i = 0; i < 100; i++) {
FeedItem feedItem = new FeedItem();
feedItem.setTitle("Test " + i);
TotComment totComment = new TotComment();
totComment.setId(1L);
totComment.setComment("howdy");
feedItem.setTotComment(totComment);
feedItem.setFeedItemType(FeedItemType.COMMENT);
feedItemDaoRepositoryImpl.save(feedItem);
}

List<FeedItem> items = feedItemDaoRepositoryImpl.findAll();

Any ideas?

Oliver Gierke
Mar 2nd, 2011, 11:45 AM
Hi,

currently SimpleMongoConverter only writes properties that has a getter method to expose it. This will change in upcoming milestones when we have sophisticated mapping options.

Cheers,
Ollie

matsientst
Mar 2nd, 2011, 12:11 PM
Shoot. Do you guys have an ETA on when thight might happen?

Oliver Gierke
Mar 3rd, 2011, 10:16 AM
It's in the works already. We just have created a ticket you might wanna follow. EVA is M2.

Cheers,
Ollie