Search in sources :

Example 1 with TransactionHS

use of org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS 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 TransactionHS

use of org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS 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 TransactionHS

use of org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS 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 TransactionHS

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

the class EmbeddedTransactionMarshaller method readFrom.

@Override
public TransactionHS readFrom(ProtoStreamReader reader) throws IOException {
    int id = reader.readInt("id");
    String description = reader.readString("description");
    int accountId = reader.readInt("accountId");
    long date = reader.readLong("date");
    double amount = reader.readDouble("amount");
    boolean isDebit = reader.readBoolean("isDebit");
    boolean isValid = reader.readBoolean("isValid");
    TransactionHS transaction = new TransactionHS();
    transaction.setId(id);
    transaction.setDescription(description);
    transaction.setAccountId(accountId);
    transaction.setDate(new Date(date));
    transaction.setAmount(amount);
    transaction.setDebit(isDebit);
    transaction.setValid(isValid);
    return transaction;
}
Also used : Date(java.util.Date) TransactionHS(org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS)

Example 5 with TransactionHS

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

the class NonIndexedEmbeddedRemoteQueryTest method testRemoteFullTextQuery.

@Test(expectedExceptions = HotRodClientException.class, expectedExceptionsMessageRegExp = "org.infinispan.objectfilter.ParsingException: ISPN028521: Full-text queries cannot be applied to property 'longDescription' in type sample_bank_account.Transaction unless the property is indexed and analyzed.")
@Override
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);
    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) Test(org.testng.annotations.Test)

Aggregations

TransactionHS (org.infinispan.query.dsl.embedded.testdomain.hsearch.TransactionHS)6 Date (java.util.Date)5 Transaction (org.infinispan.query.dsl.embedded.testdomain.Transaction)5 QueryFactory (org.infinispan.query.dsl.QueryFactory)4 TheEntity (org.infinispan.query.dsl.embedded.impl.model.TheEntity)1 Account (org.infinispan.query.dsl.embedded.testdomain.Account)1 Address (org.infinispan.query.dsl.embedded.testdomain.Address)1 Author (org.infinispan.query.dsl.embedded.testdomain.Author)1 Book (org.infinispan.query.dsl.embedded.testdomain.Book)1 NotIndexed (org.infinispan.query.dsl.embedded.testdomain.NotIndexed)1 User (org.infinispan.query.dsl.embedded.testdomain.User)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 BeforeClass (org.testng.annotations.BeforeClass)1 Test (org.testng.annotations.Test)1