本文整理了Java中org.infinispan.query.dsl.Query.setParameter
方法的一些代码示例,展示了Query.setParameter
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setParameter
方法的具体详情如下:
包路径:org.infinispan.query.dsl.Query
类名称:Query
方法名:setParameter
暂无
代码示例来源:origin: org.hibernate.ogm/hibernate-ogm-infinispan-remote
private void applyNamedParameters(QueryParameters queryParameters, Query query) {
for ( Map.Entry<String, TypedGridValue> param : queryParameters.getNamedParameters().entrySet() ) {
query.setParameter( param.getKey(), getValue( param ) );
}
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testParam() {
Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where id = :idParam");
q.setParameter("idParam", 1);
List<Transaction> list = q.list();
assertEquals(1, list.size());
assertEquals(1, list.get(0).getId());
q.setParameter("idParam", 2);
list = q.list();
assertEquals(1, list.size());
assertEquals(2, list.get(0).getId());
}
代码示例来源:origin: org.infinispan/infinispan-query
query.setParameter("nameParam1", "Unnamed")
.setParameter("nameParam2", "ww")
.setParameter("idParam1", 1000)
.setParameter("idParam2", 0);
List<Object> list = query.list();
long duration = System.nanoTime() - start; // first run is expected to take much longer than subsequent runs
query.setParameter("nameParam1", "Unnamed")
.setParameter("nameParam2", "zz")
.setParameter("idParam1", 2000)
.setParameter("idParam2", -1000);
list = query.list();
duration = System.nanoTime() - start;
query.setParameter("nameParam1", "Unnamed")
.setParameter("nameParam2", "bb")
.setParameter("idParam1", 5000)
.setParameter("idParam2", -3000);
list = query.list();
duration = System.nanoTime() - start;
代码示例来源:origin: org.infinispan/infinispan-query
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "ISPN014804: Query does not have parameters")
public void testQueryWithNoParams() {
QueryFactory qf = getQueryFactory();
qf.from(getModelFactory().getUserImplClass())
.having("name").eq("John")
.build()
.setParameter("param1", "John");
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testParam() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("gender").eq(param("param2"))
.build();
q.setParameter("param2", User.Gender.MALE);
List<User> list = q.list();
assertEquals(2, list.size());
assertEquals(User.Gender.MALE, list.get(0).getGender());
assertEquals(User.Gender.MALE, list.get(1).getGender());
q.setParameter("param2", User.Gender.FEMALE);
list = q.list();
assertEquals(1, list.size());
assertEquals(User.Gender.FEMALE, list.get(0).getGender());
}
代码示例来源:origin: org.infinispan/infinispan-query
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "ISPN014803: Parameter name cannot be null or empty")
public void testNullParamName() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq(param(null))
.build();
q.setParameter(null, "John");
}
代码示例来源:origin: org.infinispan/infinispan-query
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "ISPN014805: No parameter named 'param2' was found")
public void testUnknownParam() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq(param("param1"))
.build();
q.setParameter("param2", "John");
}
代码示例来源:origin: org.infinispan/infinispan-query
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "ISPN014803: Parameter name cannot be null or empty")
public void testEmptyParamName() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq(param(""))
.build();
q.setParameter("", "John");
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testDateParam() throws Exception {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getAccountImplClass())
.having("creationDate").eq(param("param1"))
.build().setParameter("param1", makeDate("2013-01-03"));
List<Account> list = q.list();
assertEquals(1, list.size());
assertEquals(1, list.get(0).getId());
}
代码示例来源:origin: org.infinispan/infinispan-query
@Test
public void testComplexQuery() throws Exception {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getTransactionImplClass())
.select(avg("amount"), sum("amount"), count("date"), min("date"), max("accountId"))
.having("isDebit").eq(param("param"))
.orderBy(avg("amount"), SortOrder.DESC).orderBy(count("date"), SortOrder.DESC)
.orderBy(max("amount"), SortOrder.ASC)
.build();
q.setParameter("param", true);
List<Object[]> list = q.list();
assertEquals(1, list.size());
assertEquals(5, list.get(0).length);
assertEquals(143.50909d, (Double) list.get(0)[0], 0.0001d);
assertEquals(7893d, (Double) list.get(0)[1], 0.0001d);
assertEquals(55L, list.get(0)[2]);
assertEquals(java.util.Date.class, list.get(0)[3].getClass());
assertEquals(makeDate("2013-01-01"), list.get(0)[3]);
assertEquals(2, list.get(0)[4]);
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testEqHybridQueryWithParam() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("notes").eq("Lorem ipsum dolor sit amet")
.and().having("surname").eq(param("surnameParam"))
.build();
q.setParameter("surnameParam", "Doe");
List<User> list = q.list();
assertEquals(1, list.size());
assertEquals(1, list.get(0).getId());
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testParamWithGroupBy() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getTransactionImplClass())
.select(property("accountId"), property("date"), sum("amount"))
.groupBy("accountId", "date")
.having(sum("amount")).gt(param("param"))
.build();
q.setParameter("param", 1801);
List<Object[]> list = q.list();
assertEquals(1, list.size());
assertEquals(3, list.get(0).length);
assertEquals(6225d, list.get(0)[2]);
}
代码示例来源:origin: org.infinispan/infinispan-query
@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "ISPN014825: Query parameter 'param2' was not set")
public void testMissingParam() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq(param("param1"))
.and().having("gender").eq(param("param2"))
.build();
q.setParameter("param1", "John");
q.list();
}
代码示例来源:origin: org.infinispan/infinispan-query
.build();
query.setParameter("ageParam", 30);
query.setParameter("ageParam", 32);
代码示例来源:origin: org.infinispan/infinispan-query
.select("age")
.having("age").lte(param("ageParam"))
.build().setParameter("ageParam", 30);
代码示例来源:origin: org.infinispan/infinispan-query
.build().setParameter("ageParam", 31);
代码示例来源:origin: org.infinispan/infinispan-query
.build().setParameter("ageParam", 31);
query.setParameter("ageParam", 30);
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
.select("age")
.build()
.setParameter("ageParam", 32);
内容来源于网络,如有侵权,请联系作者删除!