Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map<String,List<String> can't save to mongodb #831

Closed
wiwi111 opened this issue Aug 10, 2015 · 2 comments
Closed

Map<String,List<String> can't save to mongodb #831

wiwi111 opened this issue Aug 10, 2015 · 2 comments
Labels
Milestone

Comments

@wiwi111
Copy link

wiwi111 commented Aug 10, 2015

public class UserData{
@id
String id;
public Map < String, List < String >> data=new HashMap < String, ArrayList < String>>();
}

when I save a UserDate to mongodb ,I catched the exception

org.mongodb.morphia.mapping.MappingException: Error mapping field:*******************
at org.mongodb.morphia.mapping.Mapper.toDBObject(Mapper.java:578)
at org.mongodb.morphia.mapping.Mapper.toDBObject(Mapper.java:558)
......
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to com.mongodb.DBObject
at org.mongodb.morphia.mapping.EmbeddedMapper.writeMap(EmbeddedMapper.java:118)
at org.mongodb.morphia.mapping.EmbeddedMapper.toDBObject(EmbeddedMapper.java:28)
at org.mongodb.morphia.mapping.Mapper.writeMappedField(Mapper.java:668)
at org.mongodb.morphia.mapping.Mapper.toDBObject(Mapper.java:576)
... 29 more

@evanchooly
Copy link
Member

Can you please post a test case to the mailing list and we'll try our best to get you sorted out. Thanks.

@evanchooly evanchooly added the bug label Aug 17, 2015
@evanchooly evanchooly added this to the 1.1.0 milestone Aug 17, 2015
@evanchooly
Copy link
Member

I found the tests that I thought was covering this use case but they were testing something almost the same but not. I have it fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants