google-code-export / morphia

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

Validation misses wrong field name #305

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I had a query like:

final Query<Sentence> q = Mongo.createQuery(Sentence.class)
            .field("cluster").equal(this)
            .field("language").equal(lang);

and was getting no matches. I just found that the field is actually called 
"lang" but I was getting no validation warning about this, although I do get 
warnings if I set the wrong data type in the equal method.

Version: 1.00-SNAPSHOT

Original issue reported on code.google.com by Nic.and....@gmail.com on 21 Jul 2011 at 12:35

GoogleCodeExporter commented 9 years ago
What does the Sentence class look like?

Original comment by scotthernandez on 21 Jul 2011 at 12:46

GoogleCodeExporter commented 9 years ago
Here is the start of the Sentence class:

/**
 * An example sentence for storage in Mongo
 */
@Entity(value = "Example", noClassnameStored = true)
public class Sentence implements .... {

  @Id
  private ObjectId id = new ObjectId();

  /**
   * The text of the example
   */
  private String text;

  @Property("tHash")
  private long textHash;

  /**
   * The language code of the language
   */
  @Reference(value = "l")
  private Language lang;

Until recently the "lang" field was declared like this:

 @Reference("language")
  private Language lang;

but I'm pretty sure I got no validation errors in either case...

Original comment by Nic.and....@gmail.com on 22 Jul 2011 at 12:07

GoogleCodeExporter commented 9 years ago
You current definition using the field name alias should work just fine; it 
will not only validate but convert the field name from either form (which are 
valid, "lang" or "language") to the database field name for the query. 

I can take a look at the code but it does have a bunch of unit test that check 
for this stuff.

Original comment by scotthernandez on 5 Aug 2011 at 1:27

GoogleCodeExporter commented 9 years ago
Can't reproduce.

Original comment by scotthernandez on 28 Oct 2011 at 2:23