Search in sources :

Example 1 with Transaction

use of org.infinispan.query.dsl.embedded.testdomain.Transaction in project infinispan by infinispan.

the class EmbeddedRemoteInteropQueryTest method testDuplicateBooleanProjectionRemote.

public void testDuplicateBooleanProjectionRemote() {
    Transaction transaction = new TransactionHS();
    transaction.setId(3);
    transaction.setDescription("Hotel");
    transaction.setAccountId(2);
    transaction.setAmount(45);
    transaction.setDate(new Date(42));
    transaction.setDebit(true);
    transaction.setValid(true);
    cache.put(transaction.getId(), transaction);
    QueryFactory qf = Search.getQueryFactory(remoteCache);
    Query<Object[]> q = qf.create("SELECT id, isDebit, isDebit FROM sample_bank_account.Transaction WHERE description = 'Hotel'");
    List<Object[]> list = q.execute().list();
    assertEquals(1, list.size());
    assertEquals(3, list.get(0).length);
    assertEquals(3, list.get(0)[0]);
    assertEquals(true, list.get(0)[1]);
    assertEquals(true, list.get(0)[2]);
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) Transaction(org.infinispan.query.dsl.embedded.testdomain.Transaction) Date(java.util.Date) TransactionHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS)

Example 2 with Transaction

use of org.infinispan.query.dsl.embedded.testdomain.Transaction in project infinispan by infinispan.

the class EmbeddedRemoteInteropQueryTest method testRemoteFullTextQuery.

public void testRemoteFullTextQuery() {
    Transaction transaction = new TransactionHS();
    transaction.setId(3);
    transaction.setDescription("Hotel");
    transaction.setLongDescription("Expenses for Infinispan F2F meeting");
    transaction.setAccountId(2);
    transaction.setAmount(99);
    transaction.setDate(new Date(42));
    transaction.setDebit(true);
    transaction.setValid(true);
    cache.put(transaction.getId(), transaction);
    QueryFactory qf = Search.getQueryFactory(remoteCache);
    // Hibernate Search 6 does not support fields that are sortable and full text at the same time
    Query<Transaction> q = qf.create("from sample_bank_account.Transaction where longDescription='Expenses for Infinispan F2F meeting'");
    List<Transaction> list = q.execute().list();
    assertEquals(1, list.size());
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) Transaction(org.infinispan.query.dsl.embedded.testdomain.Transaction) Date(java.util.Date) TransactionHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS)

Example 3 with Transaction

use of org.infinispan.query.dsl.embedded.testdomain.Transaction in project infinispan by infinispan.

the class EmbeddedRemoteInteropQueryTest method testDuplicateBooleanProjectionEmbedded.

public void testDuplicateBooleanProjectionEmbedded() {
    Transaction transaction = new TransactionHS();
    transaction.setId(3);
    transaction.setDescription("Hotel");
    transaction.setAccountId(2);
    transaction.setAmount(45);
    transaction.setDate(new Date(42));
    transaction.setDebit(true);
    transaction.setValid(true);
    cache.put(transaction.getId(), transaction);
    QueryFactory qf = org.infinispan.query.Search.getQueryFactory(cache);
    Query<Object[]> q = qf.create("SELECT id, isDebit, isDebit FROM " + TransactionHS.class.getName() + " WHERE description = 'Hotel'");
    List<Object[]> list = q.execute().list();
    assertEquals(1, list.size());
    assertEquals(3, list.get(0).length);
    assertEquals(3, list.get(0)[0]);
    assertEquals(true, list.get(0)[1]);
    assertEquals(true, list.get(0)[2]);
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) Transaction(org.infinispan.query.dsl.embedded.testdomain.Transaction) Date(java.util.Date) TransactionHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS)

Example 4 with Transaction

use of org.infinispan.query.dsl.embedded.testdomain.Transaction in project infinispan by infinispan.

the class QueryDslConditionsTest method testGt.

public void testGt() {
    QueryFactory qf = getQueryFactory();
    // all the transactions greater than a given amount
    Query q = qf.from(getModelFactory().getTransactionImplClass()).having("amount").gt(1500).build();
    List<Transaction> list = q.list();
    assertEquals(1, list.size());
    assertTrue(list.get(0).getAmount() > 1500);
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) EmbeddedQueryFactory(org.infinispan.query.core.impl.EmbeddedQueryFactory) Query(org.infinispan.query.dsl.Query) Transaction(org.infinispan.query.dsl.embedded.testdomain.Transaction)

Example 5 with Transaction

use of org.infinispan.query.dsl.embedded.testdomain.Transaction in project infinispan by infinispan.

the class QueryDslConditionsTest method testLte.

public void testLte() {
    QueryFactory qf = getQueryFactory();
    Query q = qf.from(getModelFactory().getTransactionImplClass()).having("amount").lte(1500).build();
    List<Transaction> list = q.list();
    assertEquals(55, list.size());
    for (Transaction t : list) {
        assertTrue(t.getAmount() <= 1500);
    }
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) EmbeddedQueryFactory(org.infinispan.query.core.impl.EmbeddedQueryFactory) Query(org.infinispan.query.dsl.Query) Transaction(org.infinispan.query.dsl.embedded.testdomain.Transaction)

Aggregations

Transaction (org.infinispan.query.dsl.embedded.testdomain.Transaction)29 QueryFactory (org.infinispan.query.dsl.QueryFactory)21 EmbeddedQueryFactory (org.infinispan.query.core.impl.EmbeddedQueryFactory)17 Query (org.infinispan.query.dsl.Query)15 Date (java.util.Date)5 NotIndexed (org.infinispan.query.dsl.embedded.testdomain.NotIndexed)5 TransactionHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS)5 Address (org.infinispan.query.dsl.embedded.testdomain.Address)3 User (org.infinispan.query.dsl.embedded.testdomain.User)3 BeforeClass (org.testng.annotations.BeforeClass)3 Account (org.infinispan.query.dsl.embedded.testdomain.Account)2 TransactionPB (org.infinispan.client.hotrod.query.testdomain.protobuf.TransactionPB)1 TheEntity (org.infinispan.query.dsl.embedded.impl.model.TheEntity)1 Author (org.infinispan.query.dsl.embedded.testdomain.Author)1 Book (org.infinispan.query.dsl.embedded.testdomain.Book)1 AccountHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.AccountHS)1 AddressHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.AddressHS)1 UserHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.UserHS)1 Test (org.testng.annotations.Test)1