Examples of QueryFactory


Examples of org.infinispan.query.dsl.QueryFactory

      Object[] array = new Object[0];
      qf.from(User.class).having("id").in(array);
   }

   public void testSampleDomainQuery1() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all male users
      Query q = qf.from(User.class)
            .having("gender").eq(User.Gender.MALE)
            .toBuilder().build();

      List<User> list = q.list();
      assertEquals(2, list.size());
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals("John", list.get(0).getName());
      assertEquals("Spider", list.get(1).getName());
   }

   public void testSampleDomainQuery2() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all male users, but this time retrieved in a twisted manner
      Query q = qf.from(User.class)
            .not(qf.having("gender").eq(User.Gender.FEMALE))
            .and(qf.not().not(qf.having("gender").eq(User.Gender.MALE)))
            .toBuilder().build();

      List<User> list = q.list();
      assertEquals(2, list.size());
      assertEquals("John", list.get(0).getName());
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals("Spider", list.get(1).getName());
   }

   @Test(enabled = false, description = "String literal escaping is not properly done yet")   //todo [anistor] fix disabled test
   public void testStringEscape() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all transactions that have a given description. the description contains characters that need to be escaped.
      Query q = qf.from(Account.class)
            .having("description").eq("John Doe's first bank account")
            .toBuilder().build();

      List<Account> list = q.list();
      assertEquals(1, list.size());
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals(1, list.size());
      assertEquals(2, list.get(0).getId());
   }

   public void testSampleDomainQuery3() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all male users
      Query q = qf.from(User.class)
            .having("gender").eq(User.Gender.MALE)
            .toBuilder().build();

      List<User> list = q.list();
      assertEquals(2, list.size());
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals("John", list.get(0).getName());
      assertEquals("Spider", list.get(1).getName());
   }

   public void testSampleDomainQuery4() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all users ordered descendingly by name
      Query q = qf.from(User.class)
            .orderBy("name", SortOrder.DESC)
            .build();

      List<User> list = q.list();
      assertEquals(3, list.size());
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals("Spider", list.get(1).getName());
      assertEquals("John", list.get(2).getName());
   }

   public void testSampleDomainQuery5() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // name projection of all users ordered descendingly by name
      Query q = qf.from(User.class)
            .orderBy("name", SortOrder.DESC)
            .setProjection("name")
            .build();

      List<Object[]> list = q.list();
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals("Spider", list.get(1)[0]);
      assertEquals("John", list.get(2)[0]);
   }

   public void testSampleDomainQuery6() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all users with a given name and surname
      Query q = qf.from(User.class)
            .having("name").eq("John")
            .and().having("surname").eq("Doe")
            .toBuilder().build();

      List<User> list = q.list();
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals("John", list.get(0).getName());
      assertEquals("Doe", list.get(0).getSurname());
   }

   public void testSampleDomainQuery7() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all rent payments made from a given account
      Query q = qf.from(Transaction.class)
            .having("accountId").eq(1)
            .and().having("description").like("%rent%")
            .toBuilder().build();

      List<Transaction> list = q.list();
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertEquals(1, list.get(0).getAccountId());
      assertTrue(list.get(0).getDescription().contains("rent"));
   }

   public void testSampleDomainQuery8() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all the transactions that happened in January 2013
      Query q = qf.from(Transaction.class)
            .orderBy("date", SortOrder.ASC)
            .having("date").between(DATE_FORMAT.parse("2013-01-01").getTime(), DATE_FORMAT.parse("2013-01-31").getTime())
            .toBuilder().build();

      List<Transaction> list = q.list();
View Full Code Here

Examples of org.infinispan.query.dsl.QueryFactory

      assertTrue(list.get(2).getDate() > DATE_FORMAT.parse("2013-01-01").getTime());
      assertTrue(list.get(3).getDate() == DATE_FORMAT.parse("2013-01-31").getTime());
   }

   public void testSampleDomainQuery9() throws Exception {
      QueryFactory qf = Search.getQueryFactory(remoteCache);

      // all the transactions that happened in January 2013, projected by date field only
      Query q = qf.from(Transaction.class)
            .setProjection("date")
            .having("date").between(DATE_FORMAT.parse("2013-01-01").getTime(), DATE_FORMAT.parse("2013-01-31").getTime())
            .toBuilder().build();

      List<Object[]> list = q.list();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.