本文整理了Java中org.jdbi.v3.core.statement.Query.getContext
方法的一些代码示例,展示了Query.getContext
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getContext
方法的具体详情如下:
包路径:org.jdbi.v3.core.statement.Query
类名称:Query
方法名:getContext
暂无
代码示例来源:origin: jdbi/jdbi
/**
* Specify that the result set should be concurrent updatable.
*
* This will allow the update methods to be called on the result set produced by this
* Query.
*
* @return the modified query
*/
public Query concurrentUpdatable() {
getContext().setConcurrentUpdatable(true);
return this;
}
}
代码示例来源:origin: jdbi/jdbi
/**
* Executes the query, returning the result obtained from the given {@link ResultProducer}.
*
* @param <R> the type of the result
* @param producer the result producer.
* @return value returned by the result producer.
*/
public <R> R execute(ResultProducer<R> producer) {
try {
return producer.produce(this::internalExecute, getContext());
} catch (SQLException e) {
try {
close();
} catch (Exception e1) {
e.addSuppressed(e1);
}
throw new UnableToProduceResultException(e, getContext());
}
}
代码示例来源:origin: jdbi/jdbi
@Override
void configureReturner(Query q, SqlObjectStatementConfiguration cfg) {
UseRowMapper useRowMapper = getMethod().getAnnotation(UseRowMapper.class);
UseRowReducer useRowReducer = getMethod().getAnnotation(UseRowReducer.class);
if (useRowReducer != null && useRowMapper != null) {
throw new IllegalStateException("Cannot declare @UseRowMapper and @UseRowReducer on the same method.");
}
cfg.setReturner(() -> {
StatementContext ctx = q.getContext();
QualifiedType<?> elementType = magic.elementType(ctx);
if (useRowReducer != null) {
return magic.reducedResult(q.reduceRows(rowReducerFor(useRowReducer)), ctx);
}
ResultIterable<?> iterable = useRowMapper == null
? q.mapTo(elementType)
: q.map(rowMapperFor(useRowMapper));
return magic.mappedResult(iterable, ctx);
});
}
代码示例来源:origin: jdbi/jdbi
default void check() throws Exception {
Class<StatementContextExtensionMethodDao> extensionMethodDaoClass = StatementContextExtensionMethodDao.class;
Method checkMethod = extensionMethodDaoClass.getMethod("check");
ExtensionMethod extensionMethod = getHandle().getExtensionMethod();
assertThat(extensionMethod.getType()).isEqualTo(extensionMethodDaoClass);
assertThat(extensionMethod.getMethod()).isEqualTo(checkMethod);
extensionMethod = getHandle().createQuery("select * from something").getContext().getExtensionMethod();
assertThat(extensionMethod.getType()).isEqualTo(extensionMethodDaoClass);
assertThat(extensionMethod.getMethod()).isEqualTo(checkMethod);
}
}
代码示例来源:origin: jdbi/jdbi
@Test
public void findNVarcharArgument() throws Exception {
dbRule.getJdbi().useHandle(handle -> {
String value = "foo";
PreparedStatement stmt = mock(PreparedStatement.class);
handle.getConfig(Arguments.class)
.findFor(NVARCHAR_STRING, value)
.orElseThrow(IllegalStateException::new)
.apply(1, stmt, null);
verify(stmt).setNString(1, value);
handle.createQuery("no execute")
.getContext()
.findArgumentFor(NVARCHAR_STRING, value)
.orElseThrow(IllegalStateException::new)
.apply(2, stmt, null);
verify(stmt).setNString(2, value);
});
}
代码示例来源:origin: org.jdbi/jdbi3
/**
* Specify that the result set should be concurrent updatable.
*
* This will allow the update methods to be called on the result set produced by this
* Query.
*
* @return the modified query
*/
public Query concurrentUpdatable() {
getContext().setConcurrentUpdatable(true);
return this;
}
}
代码示例来源:origin: org.jdbi/jdbi3
/**
* Executes the query, returning the result obtained from the given {@link ResultProducer}.
*
* @param <R> the type of the result
* @param producer the result producer.
* @return value returned by the result producer.
*/
public <R> R execute(ResultProducer<R> producer)
{
try {
return producer.produce(this::internalExecute, getContext());
} catch (SQLException e) {
try {
close();
} catch (Exception e1) {
e.addSuppressed(e1);
}
throw new UnableToProduceResultException(e, getContext());
}
}
代码示例来源:origin: org.jdbi/jdbi3-sqlobject
default void check() throws Exception {
Class<StatementContextExtensionMethodDao> extensionMethodDaoClass = StatementContextExtensionMethodDao.class;
Method checkMethod = extensionMethodDaoClass.getMethod("check");
ExtensionMethod extensionMethod = getHandle().getExtensionMethod();
assertThat(extensionMethod.getType()).isEqualTo(extensionMethodDaoClass);
assertThat(extensionMethod.getMethod()).isEqualTo(checkMethod);
extensionMethod = getHandle().createQuery("select * from something").getContext().getExtensionMethod();
assertThat(extensionMethod.getType()).isEqualTo(extensionMethodDaoClass);
assertThat(extensionMethod.getMethod()).isEqualTo(checkMethod);
}
}
内容来源于网络,如有侵权,请联系作者删除!