예제 #1
0
  @Test
  public void noFetchJoinTest() {
    List<User> users = joiner.find(Q.from(QUser.user1));
    Assert.assertFalse(Persistence.getPersistenceUtil().isLoaded(users.get(0), "groups"));

    JoinDescription e = J.left(QGroup.group).fetch(false);

    users = joiner.find(Q.from(QUser.user1).joins(Collections.singletonList(e)));
    Assert.assertFalse(Persistence.getPersistenceUtil().isLoaded(users.get(0), "groups"));

    e.fetch(true);
    entityManager.clear();
    users = joiner.find(Q.from(QUser.user1).joins(Collections.singletonList(e)));
    Assert.assertTrue(Persistence.getPersistenceUtil().isLoaded(users.get(0), "groups"));
  }
예제 #2
0
  @Test
  public void testNestedCollectionAndSingleJoin() {
    if (noProfiles("eclipse")) {
      List<Address> addresses = joiner.find(Q.from(QAddress.address));
      Assert.assertFalse(Persistence.getPersistenceUtil().isLoaded(addresses.get(0), "user"));
      Assert.assertFalse(
          Persistence.getPersistenceUtil().isLoaded(addresses.get(0).getUser(), "groups"));
      entityManager.clear();
    }

    List<Address> addresses =
        joiner.find(
            Q.from(QAddress.address).joins(J.left(QUser.user1).nested(J.left(QGroup.group))));

    Assert.assertTrue(Persistence.getPersistenceUtil().isLoaded(addresses.get(0), "user"));
    Assert.assertTrue(
        Persistence.getPersistenceUtil().isLoaded(addresses.get(0).getUser(), "groups"));
  }
예제 #3
0
  @Test
  public void testNestedCollectionJoin() {
    List<Group> groups = joiner.find(Q.from(QGroup.group));

    Assert.assertFalse(Persistence.getPersistenceUtil().isLoaded(groups.get(0), "users"));
    Assert.assertFalse(
        Persistence.getPersistenceUtil()
            .isLoaded(groups.get(0).getUsers().iterator().next(), "addresses"));

    entityManager.clear();

    groups =
        joiner.find(
            Q.from(QGroup.group).joins(J.left(QUser.user1).nested(J.left(QAddress.address))));

    Assert.assertTrue(Persistence.getPersistenceUtil().isLoaded(groups.get(0), "users"));
    Assert.assertTrue(
        Persistence.getPersistenceUtil()
            .isLoaded(groups.get(0).getUsers().iterator().next(), "addresses"));
  }
예제 #4
0
 @Test
 public void testIsLoadedOnKnownClass() {
   final Author entity = new Author();
   assertTrue(Persistence.getPersistenceUtil().isLoaded(entity));
   assertEquals(LoadState.UNKNOWN, PersistenceUtilHelper.isLoaded(entity));
 }