RobinBattle
RobinBattle

Reputation: 228

Mongodb saves list of object

I know how to save a list of String

Now, e.g. I create my own Animal class

But when I try to save list in mongodb, it gives

java.lang.IllegalArgumentException: can't serialize class Project

I do create a new mongo collection Animal, but it is still not working.

Upvotes: 1

Views: 1166

Answers (2)

Parvin Gasimzade
Parvin Gasimzade

Reputation: 26012

If Animal class extend ReflectionDBObject then you can insert list of Animals.

Animal extends ReflectionDBObject {

}

Upvotes: 1

Eve Freeman
Eve Freeman

Reputation: 33145

You might check out Morphia or similar, where you can create object models and save them directly to Mongo.

http://code.google.com/p/morphia/

Upvotes: 1

Related Questions