Matt
Matt

Reputation: 11

Morphia Generics - Not Possible?

I'm trying to save a List of Generics(M) through Mongo/Morphia. I get this error when I tried to save:

com.google.code.morphia.mapping.MappingException: Generic Typed Class not supported: = class java.lang.Object

Does this mean that Morphia doesn't support Generics at all? Is there an alternative that would work? Using generics saves me 16 classes. There has to be an easier way that is allowed.

Surprisingly I haven't been able to find anything useful on this error.

Upvotes: 1

Views: 1067

Answers (1)

caarlos0
caarlos0

Reputation: 20663

The error says everything:

com.google.code.morphia.mapping.MappingException: Generic Typed Class not supported: = class java.lang.Object

Morphia does not support save generics in the DB, so, you can try to make a simple interface and then make all classes you want to save implement it, or something like that.

hope it helps;

Upvotes: 1

Related Questions