google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

Comparable cannot be mapped simply: Warning -- Can I ignore? #303

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'd like to use an object called CcrConcept that includes a Comparable value, 
so that it can transparently store any primitive type (like String, Long, 
Double.)  This seems to work, but I'm getting the warning below when the 
application runs.

I'm wondering:
1. Is this an OK use-case or should I be storing three separate fields for each 
type and then determining which field to use to store the value?  Are there 
major disadvantages to doing this my way?

2. Is there any way to suppress this warning?  It's happening when I call 
Morphia.map(CcrConcept.class)  Maybe we could add a quiet option for certain 
classes, or maybe do a @Property(ignoreNoSimpleMapping=true)?

What version are you using? (Morphia/Driver/MongoDB)
Morphia 1.00 snapshot
Mongo 1.8.1
Mongo java driver 2.6.3

Please include a stack trace below:
Jul 14, 2011 10:53:48 AM 
com.google.code.morphia.mapping.validation.MappingValidator$LogLine log
WARNING: MisplacedProperty complained about 
com.espoc.vericle.gwt.emr.client.phi.model.CcrConcept.value : 
com.espoc.vericle.gwt.emr.client.phi.model.CcrConcept.value is annotated as 
@Property but is a type that cannot be mapped simply (type is 
java.lang.Comparable).
Jul 14, 2011 10:53:48 AM 
com.google.code.morphia.mapping.validation.MappingValidator$LogLine log

Original issue reported on code.google.com by eli...@espoc.com on 14 Jul 2011 at 3:18

GoogleCodeExporter commented 9 years ago
This generally isn't great since all the type checking/round-tripping is lost.

There is no way to disable this, but I will look at the use-case. I don't want 
to add options for all kinds of little things but I'll take a look at this.

Since morphia doesn't store empty/null values there isn't any overhead for 
keeping a field for each type. It will only store one value for example.

Original comment by scotthernandez on 5 Aug 2011 at 9:36