本文整理汇总了Java中org.jooq.Query类的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于org.jooq包,在下文中一共展示了Query类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fetchOne
import org.jooq.Query; //导入依赖的package包/类
@Override
public <P> void fetchOne(Query query, Function<JsonObject, P> mapper, Handler<AsyncResult<P>> resultHandler) {
getConnection().setHandler(sqlConnectionResult->{
if(sqlConnectionResult.succeeded()){
log("Fetch one", ()-> query.getSQL(ParamType.INLINED));
sqlConnectionResult.result().queryWithParams(
query.getSQL(),
getBindValues(query),
executeAndClose(rs -> {
if(rs.getRows().size() > 1){
throw new TooManyRowsException(String.format("Got more than one row: %d",rs.getRows().size()));
}
Optional<P> optional = rs.getRows().stream().findFirst().map(mapper);
return (optional.orElseGet(() -> null));
},
sqlConnectionResult.result(),
resultHandler)
);
}else{
resultHandler.handle(Future.failedFuture(sqlConnectionResult.cause()));
}
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:24,代码来源:AsyncJooqSQLClientImpl.java
示例2: execute
import org.jooq.Query; //导入依赖的package包/类
@Override
public void execute(Query query, Handler<AsyncResult<Integer>> resultHandler) {
getConnection().setHandler(sqlConnectionResult->{
if(sqlConnectionResult.succeeded()){
log("Execute", ()-> query.getSQL(ParamType.INLINED));
sqlConnectionResult.result().updateWithParams(
query.getSQL(),
getBindValues(query),
executeAndClose(UpdateResult::getUpdated,
sqlConnectionResult.result(),
resultHandler)
);
}else{
resultHandler.handle(Future.failedFuture(sqlConnectionResult.cause()));
}
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:18,代码来源:AsyncJooqSQLClientImpl.java
示例3: insertReturning
import org.jooq.Query; //导入依赖的package包/类
@Override
public void insertReturning(Query query, Handler<AsyncResult<Long>> resultHandler) {
getConnection().setHandler(sqlConnectionResult->{
if(sqlConnectionResult.succeeded()){
log("Insert Returning", ()-> query.getSQL(ParamType.INLINED));
sqlConnectionResult.result().update(
query.getSQL(ParamType.INLINED),
executeAndClose(res -> res.getKeys().getLong(0),
sqlConnectionResult.result(),
resultHandler)
);
}else{
resultHandler.handle(Future.failedFuture(sqlConnectionResult.cause()));
}
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:17,代码来源:AsyncJooqSQLClientImpl.java
示例4: Execute
import org.jooq.Query; //导入依赖的package包/类
private Execute(
Connection connection,
QueryBuilder<? extends Query> queryBuilder
) {
super(
subscriber -> {
try (Query query = queryBuilder.build(connection)) {
setupUnsubscription(subscriber, query);
log.debug("Execute {}", query);
int i = query.execute();
if (!subscriber.isUnsubscribed()) {
subscriber.onNext(i);
subscriber.onCompleted();
}
} catch (Throwable t) {
handleException(t, subscriber);
}
}
);
}
开发者ID:Trunkplatform,项目名称:tiny-rxjava-jdbc,代码行数:21,代码来源:Execute.java
示例5: updateRoles
import org.jooq.Query; //导入依赖的package包/类
public boolean updateRoles(String userName, List<Role> newRoles) {
try {
dsl.transaction(config -> {
LOG.info("Removing existing roles for: " + userName);
DSL.using(config)
.delete(USER_ROLE)
.where(USER_ROLE.USER_NAME.eq(userName))
.execute();
LOG.info("Inserting roles for " + userName + " / " + newRoles) ;
DSLContext batcher = DSL.using(config);
List<Query> inserts = map(newRoles, r -> batcher
.insertInto(USER_ROLE, USER_ROLE.USER_NAME, USER_ROLE.ROLE)
.values(userName, r.name()));
batcher.batch(inserts)
.execute();
});
return true;
} catch (Exception e) {
return false;
}
}
开发者ID:khartec,项目名称:waltz,代码行数:25,代码来源:UserRoleDao.java
示例6: write
import org.jooq.Query; //导入依赖的package包/类
public int[] write(List<ChangeLog> changeLogs) {
checkNotNull(changeLogs, "changeLogs must not be null");
Query[] queries = changeLogs
.stream()
.map(changeLog -> DSL.insertInto(CHANGE_LOG)
.set(CHANGE_LOG.MESSAGE, changeLog.message())
.set(CHANGE_LOG.PARENT_ID, changeLog.parentReference().id())
.set(CHANGE_LOG.PARENT_KIND, changeLog.parentReference().kind().name())
.set(CHANGE_LOG.USER_ID, changeLog.userId())
.set(CHANGE_LOG.SEVERITY, changeLog.severity().name())
.set(CHANGE_LOG.CHILD_KIND, changeLog.childKind().map(ck -> ck.name()).orElse(null))
.set(CHANGE_LOG.OPERATION, changeLog.operation().name())
.set(CHANGE_LOG.CREATED_AT, Timestamp.valueOf(changeLog.createdAt())))
.toArray(Query[]::new);
return dsl.batch(queries).execute();
}
开发者ID:khartec,项目名称:waltz,代码行数:18,代码来源:ChangeLogDao.java
示例7: addPermission
import org.jooq.Query; //导入依赖的package包/类
@Override
public void addPermission(final String username, final PermissionView permissionView)
throws FormException {
final Query query =
jooq.insertInto(USERS_PERMISSIONS,
USERS_PERMISSIONS.USER_ID,
USERS_PERMISSIONS.PERMISSION_ID,
USERS_PERMISSIONS.GROUP_SCOPE)
.values(getUserId(username),
JooqDaoUtils.getPermissionId(permissionView.getName()),
permissionView.isGroupScoped()
? JooqDaoUtils.getContestId(permissionView.getScope())
: null);
try {
query.execute();
} catch (DataIntegrityViolationException ex) {
throw new FormException().addError("permission", "unique");
}
}
开发者ID:kTT,项目名称:adjule,代码行数:20,代码来源:JooqPermissionsDao.java
示例8: addPermissionGroup
import org.jooq.Query; //导入依赖的package包/类
@Override
public void addPermissionGroup(final String username,
final PermissionGroupView permissionGroupView)
throws FormException {
final Query query =
jooq.insertInto(USERS_PERMISSION_GROUPS,
USERS_PERMISSION_GROUPS.USER_ID,
USERS_PERMISSION_GROUPS.PERMISSION_GROUP_ID,
USERS_PERMISSION_GROUPS.GROUP_SCOPE)
.values(getUserId(username),
JooqDaoUtils.getPermissionGroupId(permissionGroupView.getCode()),
permissionGroupView.isGroupScoped()
? JooqDaoUtils.getContestId(permissionGroupView.getScope())
: null);
try {
query.execute();
} catch (DataIntegrityViolationException ex) {
throw new FormException().addError("permission", "unique");
}
}
开发者ID:kTT,项目名称:adjule,代码行数:21,代码来源:JooqPermissionsDao.java
示例9: createPermissionGroup
import org.jooq.Query; //导入依赖的package包/类
@Override
public PermissionGroupView createPermissionGroup(final PermissionGroupView permissionGroupView)
throws FormException {
final Query query =
jooq.insertInto(PERMISSION_GROUPS,
PERMISSION_GROUPS.CODE,
PERMISSION_GROUPS.NAME,
PERMISSION_GROUPS.GROUP_SCOPED)
.values(permissionGroupView.getCode(),
permissionGroupView.getName(),
permissionGroupView.isGroupScoped());
try {
query.execute();
} catch (DataIntegrityViolationException ex) {
throw new FormException().addError("code", "unique");
}
return permissionGroupView;
}
开发者ID:kTT,项目名称:adjule,代码行数:19,代码来源:JooqPermissionsDao.java
示例10: fetch
import org.jooq.Query; //导入依赖的package包/类
@Override
public <P> Single<List<P>> fetch(Query query, java.util.function.Function<JsonObject, P> mapper){
return getConnection().flatMap(executeAndClose(sqlConnection ->
sqlConnection.rxQueryWithParams(query.getSQL(), getBindValues(query)).map(rs ->
rs.getRows().stream().map(mapper).collect(Collectors.toList())
)));
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:8,代码来源:AsyncJooqSQLClientImpl.java
示例11: fetchOne
import org.jooq.Query; //导入依赖的package包/类
@Override
public <P> Single<P> fetchOne(Query query, Function<JsonObject, P> mapper){
return getConnection().flatMap(executeAndClose(sqlConnection ->
sqlConnection.rxQueryWithParams(query.getSQL(), getBindValues(query)).map(rs -> {
Optional<P> optional = rs.getRows().stream().findFirst().map(mapper);
return optional.orElseGet(() -> null);
})));
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:9,代码来源:AsyncJooqSQLClientImpl.java
示例12: execute
import org.jooq.Query; //导入依赖的package包/类
@Override
public Single<Integer> execute(Query query){
return getConnection()
.flatMap(executeAndClose(sqlConnection ->
sqlConnection
.rxUpdateWithParams(query.getSQL(), getBindValues(query))
.map(UpdateResult::getUpdated))
);
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:10,代码来源:AsyncJooqSQLClientImpl.java
示例13: insertReturning
import org.jooq.Query; //导入依赖的package包/类
@Override
public Single<Long> insertReturning(Query query) {
return getConnection()
.flatMap(executeAndClose(sqlConnection ->
sqlConnection
.rxUpdateWithParams(query.getSQL(), getBindValues(query))
.map(updateResult -> updateResult.getKeys().getLong(0)))
);
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:10,代码来源:AsyncJooqSQLClientImpl.java
示例14: getBindValues
import org.jooq.Query; //导入依赖的package包/类
private JsonArray getBindValues(Query query) {
JsonArray bindValues = new JsonArray();
for (Param<?> param : query.getParams().values()) {
Object value = convertToDatabaseType(param);
if(value==null){
bindValues.addNull();
}else{
bindValues.add(value);
}
}
return bindValues;
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:13,代码来源:AsyncJooqSQLClientImpl.java
示例15: fetch
import org.jooq.Query; //导入依赖的package包/类
@Override
public <P> void fetch(Query query, Function<JsonObject, P> mapper, Handler<AsyncResult<List<P>>> resultHandler) {
getConnection().setHandler(sqlConnectionResult->{
if(sqlConnectionResult.succeeded()){
log("Fetch", ()-> query.getSQL(ParamType.INLINED));
sqlConnectionResult.result().queryWithParams(
query.getSQL(),
getBindValues(query),
executeAndClose(rs -> rs.getRows().stream().map(mapper).collect(Collectors.toList()), sqlConnectionResult.result(), resultHandler)
);
}else{
resultHandler.handle(Future.failedFuture(sqlConnectionResult.cause()));
}
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:16,代码来源:AsyncJooqSQLClientImpl.java
示例16: fetch
import org.jooq.Query; //导入依赖的package包/类
@Override
public <P> CompletableFuture<List<P>> fetch(Query query, Function<JsonObject, P> mapper){
return getConnection().thenCompose(sqlConnection -> {
CompletableFuture<List<P>> cf = new VertxCompletableFuture<>(vertx);
sqlConnection.queryWithParams(
query.getSQL(),
getBindValues(query),
executeAndClose(rs ->
rs.getRows().stream().map(mapper).collect(Collectors.toList()),
sqlConnection,
cf)
);
return cf;
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:16,代码来源:AsyncJooqSQLClientImpl.java
示例17: fetchOne
import org.jooq.Query; //导入依赖的package包/类
@Override
public <P> CompletableFuture<P> fetchOne(Query query, Function<JsonObject, P> mapper){
return getConnection().thenCompose(sqlConnection -> {
CompletableFuture<P> cf = new VertxCompletableFuture<P>(vertx);
sqlConnection.queryWithParams(query.getSQL(), getBindValues(query), executeAndClose(rs -> {
Optional<P> optional = rs.getRows().stream().findFirst().map(mapper);
return optional.orElseGet(() -> null);
}, sqlConnection, cf));
return cf;
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:12,代码来源:AsyncJooqSQLClientImpl.java
示例18: execute
import org.jooq.Query; //导入依赖的package包/类
@Override
public CompletableFuture<Integer> execute(Query query){
return getConnection().thenCompose(sqlConnection -> {
CompletableFuture<Integer> cf = new VertxCompletableFuture<>(vertx);
JsonArray bindValues = getBindValues(query);
sqlConnection.updateWithParams(query.getSQL(), bindValues, executeAndClose(UpdateResult::getUpdated,sqlConnection,cf));
return cf;
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:10,代码来源:AsyncJooqSQLClientImpl.java
示例19: insertReturning
import org.jooq.Query; //导入依赖的package包/类
@Override
public CompletableFuture<Long> insertReturning(Query query) {
return getConnection().thenCompose(sqlConnection -> {
CompletableFuture<Long> cf = new VertxCompletableFuture<>(vertx);
sqlConnection.update(query.getSQL(ParamType.INLINED), executeAndClose(updateResult->updateResult.getKeys().getLong(0), sqlConnection, cf));
return cf;
});
}
开发者ID:jklingsporn,项目名称:vertx-jooq-async,代码行数:9,代码来源:AsyncJooqSQLClientImpl.java
示例20: init
import org.jooq.Query; //导入依赖的package包/类
private void init() {
this.context.deleteFrom(CUSTOMER);
Stream.of("a", "b", "c", "d", "e")
.forEach(name -> this.context
.insertInto(CUSTOMER)
.columns(CUSTOMER.EMAIL)
.values(name + "@email.com")
.execute());
this.context
.select()
.from(Customer.CUSTOMER)
.stream()
.forEach(cr -> {
Long customerId = cr.into(Customer.CUSTOMER.ID).value1();
Collection<Query> products =
IntStream
.range(1, new Random().nextInt(10))
.mapToObj(i -> this.context
.insertInto(PRODUCT)
.columns(PRODUCT.CUSTOMER_ID, PRODUCT.SKU)
.values(customerId, "sku" + customerId))
.collect(Collectors.toList());
this.context.batch(products).execute();
});
}
开发者ID:joshlong,项目名称:jooq-example,代码行数:29,代码来源:JooqDemoApplication.java
注:本文中的org.jooq.Query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论