Skip to content

Instantly share code, notes, and snippets.

@mgenov
Created March 16, 2012 14:50
Show Gist options
  • Save mgenov/2050396 to your computer and use it in GitHub Desktop.
Save mgenov/2050396 to your computer and use it in GitHub Desktop.
ReferenceTest.java
static class Parent {
@Id
Long id;
}
static class Child {
@Id
Long id;
Parent parent;
}
@Test
public void findChildOfAParent() {
ObjectDatastore datastore = new AnnotationObjectDatastore();
Parent parent = new Parent();
datastore.store().instance(parent).now();
Child child = new Child();
child.parent = parent;
datastore.store().instance(child).now();
datastore.disassociateAll();
List<Child> childList = datastore.find().type(Child.class)
.addFilter("parent", FilterOperator.EQUAL, parent).returnAll().now();
assertThat(childList.size(),is(equalTo(1)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment