Ejemplo n.º 1
0
  @Test
  public void unitOfWorkEvenWhenQuerying() {
    try (IDocumentStore store = new DocumentStore(getDefaultUrl(), getDefaultDb()).initialize()) {
      try (IDocumentSession session = store.openSession()) {

        Post post = new Post();
        post.setTitle("test");
        post.setBody("casing");
        session.store(post);
        session.saveChanges();

        Post single =
            session.advanced().documentQuery(Post.class).waitForNonStaleResults().single();

        assertSame(post, single);
      }
    }
  }
Ejemplo n.º 2
0
  @Test
  public void canQueryByEntityType() {
    try (IDocumentStore store = new DocumentStore(getDefaultUrl(), getDefaultDb()).initialize()) {
      try (IDocumentSession session = store.openSession()) {

        Post post = new Post();
        post.setTitle("test");
        post.setBody("casing");
        session.store(post);
        session.saveChanges();

        Post single =
            session.advanced().documentQuery(Post.class).waitForNonStaleResults().single();

        assertEquals("test", single.getTitle());
      }
    }
  }