@Test
  public void testGetShouldReturnFirstResultSetEntry()
      throws InterruptedException, ExecutionException {
    Session session = getJPO().session();

    long suffix = new Random().nextLong();

    session.delete(CommonUser.class).execute().get();

    CommonUser user = new CommonUser();
    user.setUserAge(0l);
    user.setFirstname("aaa" + suffix);
    user.setLastname("aaa" + suffix);
    session.save(user).get();

    user.setFirstname("bbb" + suffix);
    session.save(user).get();

    user.setFirstname("ccc" + suffix);
    session.save(user).get();

    assertEquals(
        session
            .find(CommonUser.class)
            .orderBy()
            .desc("firstname")
            .fetchList()
            .get()
            .get(0)
            .getFirstname(),
        session
            .find(CommonUser.class)
            .orderBy()
            .desc("firstname")
            .fetchOptional()
            .get()
            .get()
            .getFirstname());

    assertEquals(
        session
            .find(CommonUser.class)
            .orderBy()
            .asc("firstname")
            .fetchList()
            .get()
            .get(0)
            .getFirstname(),
        session
            .find(CommonUser.class)
            .orderBy()
            .asc("firstname")
            .fetchOptional()
            .get()
            .get()
            .getFirstname());
  }
  @Test
  public void testExcludeOnFind() throws InterruptedException, ExecutionException {
    Session session = getJPO().session();
    AutoId autoId = new AutoId();
    final String value = "value for test " + new Date().getTime(); // $NON-NLS-1$
    autoId.setValue(value);
    autoId = session.save(autoId).get();

    AutoId autoIdWithoutValue =
        session
            .find(AutoId.class)
            .ignore("value")
            .where(Exp.eq("id", autoId.getId()))
            .fetchUnique()
            .get(); //$NON-NLS-1$
    AutoId autoIdWithValue =
        session
            .find(AutoId.class)
            .ignore(false, "value")
            .where(Exp.eq("id", autoId.getId()))
            .fetchUnique()
            .get(); //$NON-NLS-1$

    assertEquals(autoId.getId(), autoIdWithValue.getId());
    assertNull(autoIdWithoutValue.getValue());
    assertEquals(autoId.getId(), autoIdWithValue.getId());
    assertEquals(value, autoIdWithValue.getValue());
  }