asolfre / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
0 stars 0 forks source link

Ancestor query is really an ancestorOrSelf query and returns self as the first result #160

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

I have an Order class with a LineItem class defined as:
@Entity
public class Order extends Thing{

//just primitive fields
}

@Entity
public class LineItem extends Thing{

    @Parent Ref<Order> orderRef;
... 
@Cache  
@Index  
@Entity
public class Thing implements Serializable
{   

Calling 

list = ofy().load().ancestor(order).list();

Returns the list of [order,lineitem1, lineitem2] 

Is it a bug that an ancestor query returns self as the first result?
(implying that order is its own ancestor)

If this is the expected behaviour can it be documented more clearly.

On changing the query to

list = ofy().load().type(LineItem.class).ancestor(order).list();

Returns the list of [lineitem1, lineitem2] as expected

version used
<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify</artifactId>
<version>4.0b1</version>
</dependency>

PS. Thanks for such a great project

Original issue reported on code.google.com by andrew.b...@apps4u.co on 18 May 2013 at 6:06

GoogleCodeExporter commented 9 years ago
This is the standard behavior of ancestor() in the low-level API, which I 
should probably not change. However, I have added a note to this effect to the 
javadocs for ancestor().

Original comment by lhori...@gmail.com on 18 May 2013 at 6:51