本文整理了Java中org.jdbi.v3.core.statement.Query.bindBean
方法的一些代码示例,展示了Query.bindBean
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.bindBean
方法的具体详情如下:
包路径:org.jdbi.v3.core.statement.Query
类名称:Query
方法名:bindBean
暂无
代码示例来源:origin: jdbi/jdbi
@Test
public void testDefineStrings() {
assertThat(
db.getSharedHandle().createQuery("select <a> from values(:a) union all select <b> from values(:b)")
.defineNamedBindings()
.bindBean(new DefinedBean())
.mapTo(boolean.class)
.list())
.isEqualTo(Arrays.asList(true, false));
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testDefineBoolean() {
db.getSharedHandle().setTemplateEngine(new StringTemplateEngine());
assertThat(
db.getSharedHandle().createQuery("select <a> from values(:a) <if(b)>where false=:b<endif>")
.defineNamedBindings()
.bindBean(new DefinedBean())
.mapTo(boolean.class)
.findOnly())
.isTrue();
}
代码示例来源:origin: de.digitalcollections.cudami/dc-cudami-server-backend-jdbi
@Override
public I save(I identifiable) {
identifiable.setUuid(UUID.randomUUID());
identifiable.setCreated(LocalDateTime.now());
identifiable.setLastModified(LocalDateTime.now());
IdentifiableImpl result = null;
result = dbi.withHandle(h -> h
.createQuery("INSERT INTO identifiables(created, description, identifiable_type, label, last_modified, uuid) VALUES (:created, :description::JSONB, :type, :label::JSONB, :lastModified, :uuid) RETURNING *")
.bindBean(identifiable)
.mapToBean(IdentifiableImpl.class)
.findOnly());
return (I) result;
}
代码示例来源:origin: de.digitalcollections.cudami/dc-cudami-server-backend-jdbi
@Override
public I update(I identifiable) {
identifiable.setLastModified(LocalDateTime.now());
IdentifiableImpl result = null;
// do not update/left out from statement: created, uuid
result = dbi.withHandle(h -> h
.createQuery("UPDATE identifiables SET description=:description::JSONB, identifiable_type=:type, label=:label::JSONB, last_modified=:lastModified WHERE uuid=:uuid RETURNING *")
.bindBean(identifiable)
.mapToBean(IdentifiableImpl.class)
.findOnly());
return (I) result;
}
代码示例来源:origin: de.digitalcollections.cudami/dc-cudami-server-backend-jdbi
@Override
public UserImpl update(UserImpl user) {
UserImpl result = dbi.withHandle(h -> h
.registerArrayType(Role.class, "varchar")
.createQuery("UPDATE users SET email=:email, enabled=:enabled, firstname=:firstname, lastname=:lastname, passwordHash=:passwordHash, roles=:roles, uuid=:uuid WHERE uuid=:uuid RETURNING *")
.bindBean(user)
.mapToBean(UserImpl.class)
.findOnly());
return result;
}
代码示例来源:origin: de.digitalcollections.cudami/dc-cudami-server-backend-jdbi
@Override
public UserImpl save(UserImpl user) {
user.setUuid(UUID.randomUUID());
// UserImpl result = dbi.withHandle(h -> h.createQuery(
// "INSERT INTO users(email, enabled, firstname, lastname, passwordHash, roles) VALUES (:email, :enabled, :firstname, :lastname, :passwordHash, :roles) RETURNING *")
// .bindBean(user)
// .bind("roles", user.getRoles().stream().map(Role::name).toArray(String[]::new))
// .mapToBean(UserImpl.class)
// .findOnly());
// return (S) result;
UserImpl result = dbi.withHandle(h -> h
.registerArrayType(Role.class, "varchar")
.createQuery("INSERT INTO users(email, enabled, firstname, lastname, passwordHash, roles, uuid) VALUES (:email, :enabled, :firstname, :lastname, :passwordHash, :roles, :uuid) RETURNING *")
.bindBean(user)
.mapToBean(UserImpl.class)
.findOnly());
return result;
}
内容来源于网络,如有侵权,请联系作者删除!