google-code-export / morphia

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

Validation should not warn for Key<T>/DBRefs #296

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Morphia - 1.00-SNAPSHOT
Mongo - mongodb-linux-x86_64-1.6.4
mongo-java-driver - 2.6

Given:

@Entity
Class A {
@Id
ObjectId id

String name
@Reference
B b
}

@Entity
Class B {
@Id
ObjectId id
}

Running: 

Iterable<A> as = ds.find(A.class, "name", "MorphiaRules").filter("b",
new Key<B>(B.class, id)).fetch()

Results in the following warning:

WARNING: The type(s) for the query/update may be inconsistent; using an 
instance of type 'com.google.code.morphia.Key' for the field 'A.b' which is 
declared as 'B'

Original issue reported on code.google.com by suman...@gmail.com on 6 Jul 2011 at 4:05

GoogleCodeExporter commented 9 years ago
You can suppress the log message if you use .disableValidation() in your query.
IMHO the logging should ignore this (perfectly valid) query even if validation 
is activated.

Original comment by philipp....@edistream.com on 8 May 2012 at 3:48

GoogleCodeExporter commented 9 years ago
Disabling validation is *not* a solution.
The code knows what to do in this situation and it works properly, ergo the 
warning should not be printed.

+1 for me.

Original comment by bpap...@sixgreen.com on 16 Aug 2013 at 5:30