热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.infinispan.query.dsl.QueryFactory.having()方法的使用及代码示例

本文整理了Java中org.infinispan.query.dsl.QueryFactory.having方法的一些代码示例,展示了QueryFactor

本文整理了Java中org.infinispan.query.dsl.QueryFactory.having方法的一些代码示例,展示了QueryFactory.having的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryFactory.having方法的具体详情如下:
包路径:org.infinispan.query.dsl.QueryFactory
类名称:QueryFactory
方法名:having

QueryFactory.having介绍

[英]Creates a condition on the given attribute path that is to be completed later by using it as a sub-condition.
[中]在给定的属性路径上创建一个条件,稍后将其用作子条件来完成。

代码示例

代码示例来源:origin: org.infinispan/infinispan-query

@Test(expectedExceptiOns= IllegalStateException.class)
public void testWrongQueryBuilding5() {
QueryFactory qf = getQueryFactory();
qf.from(getModelFactory().getUserImplClass())
.not(qf.having("name").eq("John"))
.not(qf.having("surname").eq("Man"))
.build();
}

代码示例来源:origin: org.infinispan/infinispan-query

@Test(expectedExceptiOns= IllegalStateException.class)
public void testWrongQueryBuilding4() {
QueryFactory qf = getQueryFactory();
qf.from(getModelFactory().getUserImplClass())
.not(qf.having("name").eq("John"))
.not(qf.having("surname").eq("Man"))
.build();
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testNot11() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.not(qf.not(
qf.having("name").eq("John")
.or(qf.having("surname").eq("Man"))))
.build();
List list = q.list();
assertEquals(2, list.size());
assertNotEquals(list.get(0).getSurname(), "Woman");
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testNot10() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.not().not(
qf.having("name").eq("John")
.or(qf.having("surname").eq("Man")))
.build();
List list = q.list();
assertEquals(2, list.size());
assertNotEquals(list.get(0).getSurname(), "Woman");
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testNot8() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.not(
qf.having("name").eq("John")
.or(qf.having("surname").eq("Man")))
.build();
List list = q.list();
assertEquals(1, list.size());
assertEquals("Spider", list.get(0).getName());
assertEquals("Woman", list.get(0).getSurname());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testAnd4() {
QueryFactory qf = getQueryFactory();
//test for parenthesis, "and" should have higher priority
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq("Spider")
.or(qf.having("name").eq("John"))
.and(qf.having("surname").eq("Man"))
.build();
List list = q.list();
assertEquals(2, list.size());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testSampleDomainQuery2() {
QueryFactory qf = getQueryFactory();
// all male users, but this time retrieved in a twisted manner
Query q = qf.from(getModelFactory().getUserImplClass())
.orderBy("name", SortOrder.ASC)
.not(qf.having("gender").eq(User.Gender.FEMALE))
.and(qf.not().not(qf.having("gender").eq(User.Gender.MALE)))
.build();
List list = q.list();
assertEquals(2, list.size());
assertEquals("John", list.get(0).getName());
assertEquals("Spider", list.get(1).getName());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testNot6() {
QueryFactory qf = getQueryFactory();
// QueryFactory.not() test
Query q = qf.from(getModelFactory().getUserImplClass())
.not(qf.not(qf.having("gender").eq(User.Gender.FEMALE)))
.build();
List list = q.list();
assertEquals(1, list.size());
assertEquals("Woman", list.get(0).getSurname());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testAnd2() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq("Spider")
.and(qf.having("surname").eq("Man"))
.build();
List list = q.list();
assertEquals(1, list.size());
assertEquals(2, list.get(0).getId());
}

代码示例来源:origin: org.infinispan/infinispan-query-dsl

@Test
public void testWithDifferentFactory1() {
QueryFactory qf1 = new DummyQueryFactory();
QueryFactory qf2 = new DummyQueryFactory();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("ISPN014809: The given condition was created by another factory");
qf1.from("MyDummyType")
.not(qf2.having("attr1").eq("1")); // exception expected
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testNot7() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("gender").eq(User.Gender.FEMALE)
.and().not(qf.having("name").eq("Spider"))
.build();
List list = q.list();
assertTrue(list.isEmpty());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testEqHybridQueryWithPredicateOptimisation() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("notes").like("%ipsum%")
.and(qf.having("name").eq("John").or().having("name").eq("Jane"))
.build();
List list = q.list();
assertEquals(1, list.size());
assertEquals("Lorem ipsum dolor sit amet", list.get(0).getNotes());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testSampleDomainQuery18() {
QueryFactory qf = getQueryFactory();
// all transactions of account with id 2 which have an amount larger than 1600 or their description contains the word 'rent'
Query q = qf.from(getModelFactory().getTransactionImplClass())
.orderBy("description", SortOrder.ASC)
.having("accountId").eq(1)
.and(qf.having("amount").gt(1600)
.or().having("description").like("%rent%")).build();
List list = q.list();
assertEquals(2, list.size());
assertEquals("Birthday present", list.get(0).getDescription());
assertEquals("Feb. rent payment", list.get(1).getDescription());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testSampleDomainQuery11() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq("John")
.and().having("addresses.postCode").eq("X1234")
.and(qf.having("accountIds").eq(1))
.build();
List list = q.list();
assertEquals(1, list.size());
assertEquals("Doe", list.get(0).getSurname());
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testOr2() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("surname").eq("Man")
.or(qf.having("surname").eq("Woman"))
.build();
List list = q.list();
assertEquals(2, list.size());
for (User u : list) {
assertEquals("Spider", u.getName());
}
}

代码示例来源:origin: org.infinispan/infinispan-query-dsl

@Test
public void testWithDifferentFactory2() {
QueryFactory qf1 = new DummyQueryFactory();
QueryFactory qf2 = new DummyQueryFactory();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("ISPN014809: The given condition was created by another factory");
qf1.from("MyDummyType")
.having("attr1").eq("1")
.and(qf2.having("attr2").eq("2")); // exception expected
}

代码示例来源:origin: org.infinispan/infinispan-query-dsl

@Test
public void testWithDifferentBuilder1() {
QueryFactory qf1 = new DummyQueryFactory();
FilterConditionContext fcc = qf1.having("attr1").eq("1");
Query q1 = qf1.from("MyDummyType")
.not(fcc)
.build();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("The given condition is already in use by another builder");
qf1.from("MyDummyType")
.not(fcc); // exception expected
}

代码示例来源:origin: org.infinispan/infinispan-query-dsl

@Test
public void testWithDifferentFactory3() {
QueryFactory qf1 = new DummyQueryFactory();
QueryFactory qf2 = new DummyQueryFactory();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("ISPN014809: The given condition was created by another factory");
qf1.from("MyDummyType")
.having("attr1").eq("1")
.or(qf2.having("attr2").eq("2")); // exception expected
}

代码示例来源:origin: org.infinispan/infinispan-query-dsl

@Test
public void testWithDifferentBuilder2() {
QueryFactory qf1 = new DummyQueryFactory();
FilterConditionContext fcc = qf1.having("attr1").eq("1");
Query q1 = qf1.from("MyDummyType")
.not(fcc)
.build();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("The given condition is already in use by another builder");
qf1.from("MyDummyType")
.having("attr1").eq("1")
.and(fcc); // exception expected
}

代码示例来源:origin: org.infinispan/infinispan-query-dsl

@Test
public void testWithDifferentBuilder3() {
QueryFactory qf1 = new DummyQueryFactory();
FilterConditionContext fcc = qf1.having("attr1").eq("1");
Query q1 = qf1.from("MyDummyType")
.not(fcc)
.build();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("The given condition is already in use by another builder");
qf1.from("MyDummyType")
.having("attr1").eq("1")
.or(fcc); // exception expected
}
}

推荐阅读
author-avatar
手机用户2502906263
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有